Skip to content

Commit 81f457d

Browse files
fs: fix failing fs.writeFile AbortController test
Moves the AbortSignal check to the end of the `do { } while();`
1 parent 6f22200 commit 81f457d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/internal/fs/promises.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,6 @@ async function writeFileHandle(filehandle, data, signal) {
255255
let remaining = data.length;
256256
if (remaining === 0) return;
257257
do {
258-
if (signal?.aborted) {
259-
throw new lazyDOMException('The operation was aborted', 'AbortError');
260-
}
261258
const { bytesWritten } =
262259
await write(filehandle, data, 0,
263260
MathMin(kWriteFileMaxChunkSize, data.length));
@@ -267,6 +264,9 @@ async function writeFileHandle(filehandle, data, signal) {
267264
data.byteOffset + bytesWritten,
268265
data.byteLength - bytesWritten
269266
);
267+
if (signal?.aborted) {
268+
throw new lazyDOMException('The operation was aborted', 'AbortError');
269+
}
270270
} while (remaining > 0);
271271
}
272272

0 commit comments

Comments
 (0)