fix(browser): allow extension reconnect when stale websocket lingers (AI-assisted)#20688
Closed
HOYALIM wants to merge 1 commit intoopenclaw:mainfrom
Closed
fix(browser): allow extension reconnect when stale websocket lingers (AI-assisted)#20688HOYALIM wants to merge 1 commit intoopenclaw:mainfrom
HOYALIM wants to merge 1 commit intoopenclaw:mainfrom
Conversation
Contributor
Author
|
Rebased on latest main (including 7e54b6c) and resolved conflicts in extension-relay. |
cb37628 to
db3383b
Compare
Contributor
Author
|
Thanks for the review. All checks are green on latest commit. Ready to merge when convenient :) |
Closed
18 tasks
18 tasks
Contributor
|
This fix is already in That landed commit already includes:
Closing as already landed to avoid duplicate merge. |
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.
Summary
/extensionWebSocket upgrade returned409 Extension already connectedwheneverextensionWswas non-null, including reconnect races where the old socket was alreadyCLOSING/CLOSED.Unexpected response code: 409, forcing manual re-attach and reducing browser relay reliability./extensionnow returns 409 only when the existing extension socket is actuallyOPEN.CLOSING/CLOSED), relay terminates/clears it and accepts the new connection.AI-assisted Disclosure
pnpm build,pnpm check,pnpm test)Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
Unexpected response code: 409reconnect failures.Security Impact (required)
Yes/No): NoYes/No): NoYes/No): NoYes/No): NoYes/No): NoYes, explain risk + mitigation: N/ARepro + Verification
Environment
/extension,/cdp)127.0.0.1:18792)Steps
/extension.Expected
Actual
Unexpected server response: 409.Evidence
Before:
src/browser/extension-relay.test.ts > allows immediate reconnect when prior extension socket is closingUnexpected server response: 409After:
pnpm vitest run --config vitest.unit.config.ts src/browser/extension-relay.test.ts(9/9 passing)pnpm build(pass)pnpm check(pass)pnpm test(pass: 736 files, 6126 tests)Human Verification (required)
build/check/test)Compatibility / Migration
Yes/No): YesYes/No): NoYes/No): NoFailure Recovery (if this breaks)
cb37628e1.src/browser/extension-relay.tssrc/browser/extension-relay.test.tsRisks and Mitigations
readyState !== OPEN; explicit regression test preserves live-duplicate 409 behavior.extensionWs !== ws) + regression coverage.Greptile Summary
Fixed WebSocket reconnection race condition in Chrome extension relay by allowing reconnects when the prior socket is stale (
CLOSING/CLOSED) rather than rejecting all reconnect attempts. The fix includes an identity guard in the close handler to prevent late close events from cleared sockets from wiping active connections./extensionendpoint to only reject with 409 whenextensionWs.readyState === WebSocket.OPENextensionWs !== ws) in close handler to prevent replaced sockets from clearing active stateConfidence Score: 5/5
readyStatebefore rejecting connections, safely terminates stale sockets, and includes an identity guard to prevent state corruption from late close events. Both positive (stale reconnect) and negative (duplicate live connection) test cases are present, and all test gates pass.Last reviewed commit: cb37628
(4/5) You can add custom instructions or style guidelines for the agent here!