Repository navigation
fix(node): send the head for stream bodies that end without data - #339
Conversation
|
@danielroe is attempting to deploy a commit to the unjs Team on Vercel. A member of the Team first needs to authorize it. |
|
Caution Review failedThe pull request is closed. No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Handle and verify stream end src/adapters/_node/send.ts, test/node-streams.test.ts |
pipeBody writes the configured response head and ends the response when a stream has already ended or ends without emitting readable. Tests check response status, status text, headers, empty bodies, error status, and listener cleanup. |
Priority:
Estimated code review effort: 2 (Simple) | ~8 minutes
Change: Bug fix · Severity of issue fixed: Medium
Possibly related issues
Merge Risk: 
Moderate · up to 9792c
-
Empty Node stream bodies now get a response head instead of hanging, which fixes the reported issue. An unusual stream that errors after ending could still crash the process because no error listener remains. Keep an error listener until the stream closes before merging.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Title check
-
Explanation
The title "fix(node): send the head for stream bodies that end without data" matches the main change. The raw summary shows that pipeBody in src/adapters/_node/send.ts now listens for
endand writes the intended headers when a Node stream ends without data. The linked objectives describe the same hang, and the added tests cover empty IncomingMessage bodies and already-ended streams. The title is specific and accurate, and it follows the conventional commit style.
Full details: Linked Issues check
-
Explanation
Issue
#338requires an ended empty Node stream to receive a response.pipeBodynow checksreadableEnded, listens forend, writes the configured head, and ends the response. The tests cover an emptyIncomingMessage, an already-ended stream, and a stream that ends later. The tests verify status, status text, headers, and an empty body.
Full details: Out of Scope Changes check
-
Explanation
The source change is limited to empty or already-ended Node stream handling in
pipeBody. The added tests cover the linked issue and adjacent event timing cases. No unrelated implementation or test changes appear in the reviewed diff.
-
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
A rabbit checks the stream at dawn
The empty bytes have all withdrawn
The headers reach the waiting door
The response ends; it waits no more
I twitch my nose and hop along
A quiet end can still be strong
Comment @coderabbitai help to get the list of available commands.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
commit: |
Also add a deterministic test for streams that emit 'end' without 'readable'.
resolves #338
in Nitro 3 dev mode, every empty non-204/304 response proxied from the worker hangs until the client times out
this broke CI in nuxt/nuxt#36671 and will probably break any user too...
this started happening when env-runner started passing FastResponse to srvx, and there's a good diagnosis in #338 from @onmax....
the bug originated in 4051f22 (v0.11.12), which started deferring the head until
'readable', and it was then activated by unjs/httpxy#186 and unjs/env-runner#92...so, this PR also listens for 'end' before writing the head, and checks
readableEndedup frontSummary by CodeRabbit