Repository navigation
Conversation
There was a problem hiding this comment.
No issues found across 2 files
Heads up: you’re close to your flex budget. Increase your flex budget so reviews don’t pause.
View guided diff | Re-trigger cubic
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.
Issue for this PR
Closes #154
Type of change
What does this PR do?
Session.invalidate()clearsthis.wsbefore closing the socket. When the close event lands, the socket's close listener seesthis.ws !== ws, treats the socket as superseded, and returns without drainingpending— so a CDP call still waiting for its response never settles.invalidate()now rejects and clears the pending calls itself, with the same invalidation error, before closing the socket. That mirrors how the close listener and the socket-replacement path inopenWsalready drainpending. Nothing else changes: later calls still fail with the invalidation error, and a socket that closes on its own still rejects pending calls through the close listener.How did you verify your code works?
invalidate(); after the fix it rejects immediately with the invalidation error.packages/bcode-browser/test/cdp-session.test.tsagainst a never-answering server — one in-flight call, and two in-flight calls — both reject with the invalidation error. On the unpatched code both tests hang and hit the test timeout.bun testinpackages/bcode-browser: 50 pass, 8 skipped (live browser/network tests), 0 fail.tsgo --noEmitinpackages/bcode-browser: clean.Screenshots / recordings
Not applicable — no UI change.
Checklist
Summary by cubic
Fixes
Session.invalidate()so in-flight CDP calls reject instead of hanging forever. Previously,invalidate()cleared the socket reference before closing it, which made the socket's close listener treat the socket as superseded and skip draining pending calls, leaving waiting calls unsettled. Nowinvalidate()rejects and clears pending calls with the invalidation error itself before closing the socket; a socket that closes on its own still settles pending calls via the close listener.Two regression tests in
packages/bcode-browser/test/cdp-session.test.tscover one and two in-flight calls against a server that never answers — both reject with the invalidation error.Written for commit 628be43. Summary will update on new commits.