Repository navigation
Conversation
j-mercker
requested review from
changt,
cloudwebrtc,
hiroshihorie and
xianshijing-lk
as code owners
November 22, 2026 12:51
There was a problem hiding this comment.
🔍 Devin Review: 1 flag
Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
This branch has not been deployed
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.
Problem
On web, every signal connection that fails after it opened throws an uncaught
Bad state: Future already completed. The connection itself is handled correctly (the socket is disposed and the engine reconnects), but each drop shows up in the app's error reporting as an uncaught exception.Seen on web with 2.13.2 on LiveKit Cloud: 10 reports from 9 users over 2 days on one build, each within about a second of the SDK starting a reconnect. Symbolicated:
Cause
LiveKitWebSocketWeb.connectcompletes itsCompleteronopenand callscompleteErroronerror, and theerrorlistener stays attached afterconnectreturns. When an open connection later fails, the browser fireserrorand thenclose, socompleteErrorruns on a completedCompleter. Thecloselistener set up inLiveKitWebSocketWeb._already handles the failure.Reproduces in Chrome 158 with a server that completes the handshake and then sends a frame with reserved bits set:
openat 6 ms,errorat 1008 ms,close1006, then the second completion throws.Repro:
python3 bad_ws_server.pyandpython3 -m http.server 8766 --bind 127.0.0.1, then open http://127.0.0.1:8766/index.htmlbad_ws_server.pyindex.htmlFix
errorlistener completes theCompleteronly if it has not completed yet.Testing
test/support/websocket_web_test.dart, "an open connection that fails is disposed without an uncaught error". AspawnHybridUriserver (test/support/websocket_web_error_server.dart) opens the socket and then breaks the protocol, and the test checks thatonDisposeruns and nothing reaches the zone. It fails onmainwithBad state: Future already completedand passes here. Like the other@TestOn('browser')tests it runs withflutter test --platform chrome, not in the VM run in CI.Notes
mainbehave the same.