Repository navigation
fix(zero-cache): don't crash when a client resets during a WebSocket handoff - #112
Merged
Merged
Conversation
…handoff Nothing listened for errors on an upgraded socket while the runner waited for a worker to hand it to, or on the socket a worker received over IPC before ws took it. A client that reset the connection in that window raised read ECONNRESET as an uncaught exception, which exits the process and takes zero-cache down. The Swift chaos fuzz hit it in CI: zero-cache exited with code 13 and every later end-to-end test was refused. The handoff handler now destroys the socket on an error until ws takes it over. Amp-Thread-ID: https://ampcode.com/threads/T-c513a037-a257-45e0-b9a9-15c15edfe859 Co-authored-by: tmm <tmm@tmm.dev>
Amp-Thread-ID: https://ampcode.com/threads/T-c513a037-a257-45e0-b9a9-15c15edfe859 Co-authored-by: tmm <tmm@tmm.dev>
This was referenced Nov 6, 2026
tmm
added a commit
that referenced
this pull request
Nov 10, 2026
…ay (#129) When a connection closes while the runner sends it to the dispatcher, Node delivers the handoff message without the socket. Since #112 the dispatcher calls socket.on('error', …) as soon as the message arrives, so a missing socket threw a TypeError, an uncaught exception that exits zero-cache with code 13. main's Swift end-to-end job hit it at a0df53f: the dispatcher died at websocket-handoff.ts:80 right after the chaos fuzz cut two clients, and every later end-to-end test timed out. The dispatcher now drops such a message, as installWebSocketReceiver already does in the syncer. Amp-Thread-ID: https://ampcode.com/threads/T-0d2ed206-a5dd-4f42-9b68-c56e6b23e8f6 Co-authored-by: Amp <amp@ampcode.com>
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.
zero-cache crashes when a client resets its TCP connection while a WebSocket handoff is pending. Found by the Swift chaos fuzz (#111).
What happens. The handoff handler takes the raw socket from the HTTP
upgradeevent, or from the parent over IPC, and nothing listens for its errors untilwstakes it over. The runner's handoff waits forgetWorker()first. A client RST in that window raisesread ECONNRESETas anuncaughtException, and the process exits:In #111's Linux end-to-end job, every end-to-end test after that point was refused on port 4848. The same crash happened in the runner on a local orb, where the service supervisor restarted zero-cache and hid it.
Fix. Until
wstakes the socket, the handler destroys it on an error. The listener is removed just beforehandleUpgrade, which adds its own.Checked.
websocket-handoff.test.tssends an upgrade, then resets the connection while the handoff waits. It fails without the fix with that sameread ECONNRESET, and passes with it.No changeset: like #63, it's a zero-cache fix that this fork doesn't publish.