fix(http): settle failing custom route streams - #360
Merged
punkpeye merged 2 commits intoSep 7, 2026
Merged
Conversation
punkpeye
requested changes
Sep 6, 2026
punkpeye
left a comment
Owner
There was a problem hiding this comment.
Stops the fall-through correctly. One change needed: settle with destroy(), not end().
Verified with res.end():
- chunked body: client gets the truncated body with a clean terminator, so it looks complete
Content-Lengthset: client keeps waiting for the missing bytes, so the hang moves client-side
Replace the if (!res.writableEnded) { res.end(); } block with:
// Drop the connection so the client sees the failure. end() writes nothing
// after destroy() but sets writableEnded, which mcp-proxy checks before
// running its own fallback response.
res.destroy();
res.end();Test:
await expect(
fetch(`http://localhost:${port}/failing-stream`).then((r) => r.text()),
).rejects.toThrow();Checked locally: both cases reject in ms, 24/24 route tests pass, no unhandled rejections.
Owner
|
Pushed the
Thanks for the fall-through fix — that part was right. |
punkpeye
approved these changes
Sep 7, 2026
punkpeye
left a comment
Owner
There was a problem hiding this comment.
destroy() fix pushed and green.
|
🎉 This PR is included in version 4.20.5 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Summary
A Hono response body can reject asynchronously after the first chunk. At that point
respondWithCustomRoute()cannot send an error response, but returningfalsetells the outer handler that no custom route matched. The request then falls through and can hang or attempt to write a second response.Validation