Repository navigation
quic: destroy stream on invalid promise body - #66260
Merged
nodejs-github-bot merged 1 commit intoOct 6, 2026
Merged
Conversation
Collaborator
|
Review requested:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #66260 +/- ##
==========================================
+ Coverage 90.30% 90.37% +0.06%
==========================================
Files 789 790 +1
Lines 272880 273847 +967
Branches 52106 52382 +276
==========================================
+ Hits 246423 247477 +1054
+ Misses 16918 16858 -60
+ Partials 9539 9512 -27
🚀 New features to boost your workflow:
|
pimterry
approved these changes
Sep 25, 2026
pimterry
left a comment
Member
There was a problem hiding this comment.
Thanks @christianaurichzm! Good find, fix LGTM.
Would be nice to avoid the extra Then step imo, but I don't feel strongly.
When `setBody()` receives a promise that resolves to an unsupported body type, `configureOutbound()` throws inside the fulfillment handler. The rejection handler only covered the original promise, so the error rejected a discarded promise and crashed the process as an unhandled rejection. Catch errors thrown by `configureOutbound()` in the fulfillment handler and destroy the stream with them, as the rejection handler already does. For an unsupported resolved value, `stream.closed` now rejects with the same `ERR_INVALID_ARG_TYPE` that `setBody()` throws synchronously. Signed-off-by: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
christianaurichzm
force-pushed
the
quic-promise-body-invalid
branch
from
September 25, 2026 19:02
3649ec9 to
413eb7d
Compare
pimterry
approved these changes
Oct 5, 2026
Collaborator
Collaborator
|
Landed in 8314231 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
stream.setBody(Promise.resolve(42))crashes the process with an unhandled rejection, whilestream.setBody(42)throwsERR_INVALID_ARG_TYPEsynchronously.configureOutbound()calls itself with the resolved value inside the fulfillment handler ofPromisePrototypeThen(). The rejection handler only coversbodyitself rejecting, so when that call throws, the error goes to the promise returned byPromisePrototypeThen(), which nothing handles.This wraps that call in a
try/catchand destroys the stream with the error, the same way the rejection handler already does. The same goes forERR_INVALID_STATEwhen the promise resolves to aFileHandlealready in use by another stream. Nothing changes for a body that rejects.On
mainthe new test crashes. With this change alltest/parallel/test-quic-*.mjstests pass andmake lintis clean.