Repository navigation
fix(1.x): abort event.request.signal when the client disconnects - #2340
Merged
Merged
Conversation
On Node, vinxi builds the web request without a signal tied to the connection, so event.request.signal never aborted and API routes kept running after the client went away. - Wrap the request with a signal that aborts when the response closes before it was fully sent, or with the request error if the request failed. - Combine it with the original signal using AbortSignal.any, so the platform signal on web runtimes still applies. - Store the wrapped request on event.web, since it takes over the body and later getWebRequest calls must return the same request. Fixes #1753. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: cf8926d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
brenelz
approved these changes
Oct 13, 2026
2 tasks done
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.
Fixes #1753 on the 1.x line.
On Node,
event.request.signalnever aborts, so an API route cannot tell when the client goes away and keeps running. The issue's use case is an AI chat route that keeps streaming tokens from the provider after the user cancels.Cause
createFetchEventuses vinxi'sgetWebRequest. On Node, vinxi'stoWebRequestH3builds theRequestwithout asignal, so the signal is a fresh one that nothing ever aborts. This is why the reporter had to fall back toevent.nativeEvent.node.req.on("close").Fix
createFetchEventnow wraps the request with a signal that aborts when the Node response closes before it was fully sent, the same rule srvx uses in 2.0:res.writableEndedis false, so a normal finish does not abort.The new signal is combined with the original one using
AbortSignal.any. On web runtimes, h3 gives the event the platform request, whose signal already works, and it keeps working. h3 usesnode-mock-httpfor the Node objects there. Its response setswritableEndedbefore it emitsclose, anddestroy()removes listeners, so it cannot trigger a false abort. 1.x requires Node 22, soAbortSignal.anyis available.The wrapped request takes over the original request's body, so it is also stored on
event.web.request. LatergetWebRequestcalls then return the same request and can still read the body.Testing
apps/testsfrom this branch, with a temporary API route that listens forabort:aborted = false.aborted = false.fetchEvent.spec.ts: abort on early close, no abort after a full send, abort with the request error, keeping the platform signal, and keeping the body on the shared request. The 2 tests for the bug fail without the fix.@solidjs/start:test:ci(95 tests),typecheckandbuildpass.apps/tests:unit:ciand the full Cypress suite pass against the production build (19 tests, including the 13 server function tests that send request bodies).Note: this targets
1.x, so merging it will not close #1753 on its own.🤖 Generated with Claude Code