fix crash on abort when body is not a stream#1852
Conversation
rsbasic
left a comment
There was a problem hiding this comment.
Review: APPROVE (bug fix, LOW risk)
Author: @sbingner — established developer (account since 2010, 758 followers).
This fixes a crash that occurs when aborting a request where the body stream object is different from the source body. The current code assumes body === stream and attaches an error handler only to body. When they differ, aborting can trigger an unhandled error on stream.
The fix adds a parallel error handler on stream when stream !== body. The error wrapping logic is identical to the existing handler — converts non-FetchBaseError instances to FetchError with type 'system'. This is defensive programming, not a behavioral change.
Scope check: Only touches src/body.js, adds 9 lines, no imports changed, no dependencies added. The pattern matches the existing error handler 10 lines below it.
Verdict: Safe to merge. Small, defensive fix for a real crash scenario from a credible contributor. Has been open since July 2025 — 8 months waiting for review.
Purpose
This causes node-fetch to stop crashing node if you abort a request
Changes
Additional information