From 81f457d650fd055c3f3e31a4707d6b9faa7b4009 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20L=C3=B6wenstein?= Date: Sun, 22 Aug 2021 12:53:57 +0200 Subject: [PATCH] fs: fix failing fs.writeFile AbortController test Moves the AbortSignal check to the end of the `do { } while();` --- lib/internal/fs/promises.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/internal/fs/promises.js b/lib/internal/fs/promises.js index 696c904be35c7f..bd62dcae097295 100644 --- a/lib/internal/fs/promises.js +++ b/lib/internal/fs/promises.js @@ -255,9 +255,6 @@ async function writeFileHandle(filehandle, data, signal) { let remaining = data.length; if (remaining === 0) return; do { - if (signal?.aborted) { - throw new lazyDOMException('The operation was aborted', 'AbortError'); - } const { bytesWritten } = await write(filehandle, data, 0, MathMin(kWriteFileMaxChunkSize, data.length)); @@ -267,6 +264,9 @@ async function writeFileHandle(filehandle, data, signal) { data.byteOffset + bytesWritten, data.byteLength - bytesWritten ); + if (signal?.aborted) { + throw new lazyDOMException('The operation was aborted', 'AbortError'); + } } while (remaining > 0); }