Repository navigation
fix(db-sync): the node server answers a websocket upgrade whose auth fails - #13692
Closed
yuxi-liu-wired wants to merge 1 commit into
Closed
yuxi-liu-wired wants to merge 1 commit into
yuxi-liu-wired wants to merge 1 commit into
Conversation
yuxi-liu-wired
force-pushed
the
fix/db-sync-ws-upgrade-auth-error
branch
from
October 16, 2026 18:35
5e46156 to
18502c8
Compare
Contributor
Author
|
Combined with the other PRs that change the same files into #13781. |
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.
A websocket upgrade to the Node sync server whose authentication fails with an error (a malformed bearer token such as
x.y.z, or a JWKS fetch failure) is never answered: the socket is neither upgraded, refused nor closed, and stays open until the client gives up. The same failure on an HTTP request gets a 500 (node-server-returns-500-when-auth-claims-rejects-test).Cause: the server's
"upgrade"handler runsaccess-allowed?(which callsauth/auth-claims) and the readiness check in a promise chain with nocatch. A token read as no user is dropped (allowed?is false), but a rejectedauth-claimsskips every branch, so nothing is written to the socket. Anyone can hold sockets open on the server this way without valid credentials; no graph data is reached.Fix: the chain gets a
catchthat logs:db-sync/node-ws-upgrade-failedand answers the upgrade with a 500 (then closes the socket), unless the socket is already gone.reject-ws-upgrade!now writes the reason phrase for its status (it always wroteConflict, which was right only for its one caller, the 409).Test:
logseq.db-sync.node-server-test/node-server-answers-ws-upgrade-when-auth-claims-rejects-test: withauth-claimsrejecting (as the existing HTTP test does), a websocket upgrade to/sync/graph-xgets an HTTP 500. On master it gets no answer and the test fails; with the fix it passes, along with the rest oflogseq.db-sync.node-server-testandlogseq.db-sync.worker-handler-ws-test(12 tests, 0 failures). Lint as in CI fordeps/db-syncand the app.Found by mutation testing (triage of
node/server.cljs).