Repository navigation
fix(sync): handle replication stream errors on the sync websocket - #77
Open
gmaclennan wants to merge 3 commits into
Open
gmaclennan wants to merge 3 commits into
gmaclennan wants to merge 3 commits into
Conversation
The pipeline promise returned by wsCoreReplicator was discarded, so a replication stream error (for example a failed noise handshake from a client sending a bad frame) became an unhandled rejection and node exited the whole process. Log it on the request logger and terminate the offending socket if it is still open. Also log unhandled rejections at process level in server.js as defence in depth so a future miss is visible without taking the server down.
gmaclennan
commented
Nov 5, 2026
gmaclennan
marked this pull request as ready for review
November 5, 2026 12:24
gmaclennan
requested review from
RangerMauve
and
a balanced review from Copilot
November 5, 2026 14:46
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.
When a sync client sends a bad frame instead of a noise handshake (or the handshake fails for any other reason), the whole cloud process exits with code 1. Every other websocket connection and any in-flight REST download is dropped with it. An internal repro hit this repeatedly.
The
/sync/:projectPublicIdhandler insrc/routes.jsdiscards the promise returned bywsCoreReplicatorinsrc/ws-core-replicator.js, which is thenode:stream/promisespipeline promise. When the replication stream errors that promise rejects with nobody listening, and node 20 treats an unhandled rejection as fatal.This change catches the rejection in the route, logs it on the request logger at warn and terminates the offending socket if it is still open. It also adds a process-level
unhandledRejectionhandler insrc/server.jsthat logs at error and keeps the process running, so a future miss shows up in logs instead of taking the server down. The new test keeps sending garbage frames on the sync websocket until the server closes the socket, then checks that no unhandled rejection fired and that the server still answersGET /info. It has to keep sending because the handler awaitsgetProjectbefore attaching the pipeline, and a frame that arrives before then is dropped; that early-frame gap is pre-existing and worth a separate issue.One question for reviewers: is warn the right level for a per-connection replication failure? Garbage from one client is not a server fault, so info may be enough, but warn makes repeated failures from a misbehaving client easier to spot.