Skip to content

Commit 3d36289

Browse files
committed
Fix bug in body buffering when body is insta-aborted
The preexisting code tried to reject the promise and attach failure metadata before it was actually initialized. It's now deferred. This is a tricky edge case to hit and didn't seem to come up before the recent tightening of body & abort handling.
1 parent 014f0ec commit 3d36289

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/util/buffer-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export const streamToBuffer = (input: stream.Readable, maxSize = MAX_BUFFER_SIZE
9393

9494
// If stream has already finished/aborted, resolve accordingly immediately:
9595
if (input.readableEnded) return resolve(Buffer.from([]));
96-
if (input.readableAborted) return failWithAbortError();
96+
if (input.readableAborted) return setImmediate(failWithAbortError);
9797

9898
let currentSize = 0;
9999
const onData = (d: Buffer) => {

0 commit comments

Comments
 (0)