Repository navigation
Conversation
send() discards the payload when the reply has already been sent. If that payload is a thenable, nothing ever attaches a handler to it, so a later rejection escapes as an unhandled rejection, which terminates the process by default on modern Node. Attach a handler that logs it instead. Reachable today from plain JS regardless of the declared types, e.g. a second send() in a handler that already replied. Signed-off-by: skdas20 <skdas5405@gmail.com>
metcoder95
reviewed
Sep 3, 2026
| // observe its outcome, so an eventual rejection would surface as an | ||
| // unhandled rejection and terminate the process by default. Attach a | ||
| // handler that reports it instead. | ||
| if (payload !== null && typeof payload === 'object' && typeof payload.then === 'function') { |
Member
There was a problem hiding this comment.
nit:
Suggested change
| if (payload !== null && typeof payload === 'object' && typeof payload.then === 'function') { | |
| if (payload != null && typeof payload.then === 'function') { |
metcoder95
approved these changes
Sep 3, 2026
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.
Split out of #6526, as offered there — this half stands on its own and does not depend on whether
send(promise)becomes a supported API.The bug
send()drops the payload when the reply has already been sent:If that dropped payload is a thenable, nothing has attached a handler to it. A later rejection therefore escapes as an unhandled rejection, which terminates the process by default on modern Node.
This is reachable from plain JavaScript today regardless of the declared types — any second
send()in a handler that has already replied:The fix
Attach a handler to the dropped thenable that logs the rejection, so it is reported rather than fatal. The payload is still discarded and the existing
FST_ERR_REP_ALREADY_SENTwarning is unchanged.Testing
Added
a promise rejecting after the reply was sent is logged, not left unhandled, asserting the response is unaffected and the rejection reaches the logger.main(the rejection goes unhandled).test/internals/reply.test.js, lint clean.@mcollina — this is option (2) from my last comment on #6526. I've kept it deliberately narrow so it can be judged on its own; happy to close #6526 entirely if you'd prefer the feature not to land.