fix(ws): harden auth error handling#2946
Merged
Merged
Conversation
|
@YOMXXX is attempting to deploy a commit to the IndexLabs Team on Vercel. A member of the Team first needs to authorize it. |
Collaborator
|
Thanks for the thorough fix, @YOMXXX! Reviewed by two agents — both recommended merging this PR as a superset of #2945 (closes #2933 + #2934 together, stronger regression tests, and the Merging now. A small follow-up will be opened to truncate the raw (MUL-2490) |
This was referenced May 21, 2026
Bohan-J
added a commit
that referenced
this pull request
May 21, 2026
The post-#2946 onmessage guard logs the raw event.data alongside the warning. A malformed or rogue server can stream arbitrarily large garbage and bloat the renderer / desktop main-process log buffers, so cap the logged payload to the first 200 chars and append a "(truncated, N chars total)" suffix when truncation occurs. MUL-2490 Co-authored-by: multica-agent <github@multica.ai>
6 tasks
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.
What does this PR do?
Hardens WebSocket auth/error handling on both sides of the connection.
On the server, first-message auth and
auth_ackwrites now checkWriteMessageerrors and log write failures with frame/user/workspace context. On the client, malformed WebSocket frames are logged and skipped instead of throwing out of theonmessagecallback and preventing later frames from being processed.Related Issue
Closes #2933
Closes #2934
Type of Change
Changes Made
packages/core/api/ws-client.ts; unparseable frames now calllogger.warnand return.writeWSAuthFrame/writeWSAuthErrorAndClosehelpers inserver/internal/realtime/hub.go.auth_ackto log failed writes instead of discarding errors.slogoutput when auth frame writes fail.How to Test
WSClient.onmessage; it should log and skip without throwing.Verification
pnpm --filter @multica/core exec vitest run api/ws-client.test.tspnpm --filter @multica/core typecheckpnpm --filter @multica/core testpnpm --filter @multica/core lint(exited 0 with one pre-existing hook warning inpackages/core/platform/auth-initializer.tsx)cd server && go test ./internal/realtime -run TestWriteWSAuthFrameLogsWriteErrorscd server && go test ./internal/realtimecd server && go test ./...pnpm typecheckgit diff --checkChecklist
apps/web/features/landing/i18n/) and relevant docs (apps/docs/content/docs/)apps/docs/content/docs/developers/conventions.zh.mdx(terminology, mixed-rule fortask/issue/skill)AI Disclosure
AI tool used: Codex
Prompt / approach: Investigated #2933/#2934 as one WebSocket reliability issue. Traced the server first-message auth write paths and the client
onmessagedispatch loop, wrote failing regression tests first, then made the narrowest changes to log failed auth frame writes and skip malformed client frames without disrupting later messages.Screenshots (optional)
N/A - WebSocket reliability/logging behavior only.