Skip to content

Commit

Permalink
fs: fix failing fs.writeFile AbortController test
Browse files Browse the repository at this point in the history
Moves the AbortSignal check to the end of the `do { } while();`
  • Loading branch information
MoritzLoewenstein committed Aug 22, 2021
1 parent 6f22200 commit 81f457d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/internal/fs/promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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);
}

Expand Down

0 comments on commit 81f457d

Please sign in to comment.