fix(browser): name the CloakBrowser session cap instead of "target closed" (#225) - #467
Open
Agnik47 wants to merge 1 commit into
Open
fix(browser): name the CloakBrowser session cap instead of "target closed" (#225)#467Agnik47 wants to merge 1 commit into
Agnik47 wants to merge 1 commit into
Conversation
…osed" (agentrhq#225) A second concurrent profile exits with code 76 on CloakBrowser's free tier, and webcmd reported it as `page.goto: Target page, context or browser has been closed` — the same text an externally closed or crashed browser produces. The reporter traced the daemon and profile multiplexing end to end before finding the licensing cap, because the error pointed nowhere. Two mappings, both onto the existing BrowserConnectError / 'profile-disconnected': - A launch that fails with exit code 76 now says so and names the license key. - A navigation that still fails with a closed-context error after the existing one-shot recovery retry now reports which profile disconnected, and keeps the Playwright text as the cause rather than dropping it. Another live profile is the one cause we can actually check, so it decides the hint: with a second profile up, the cap is named; alone, the hint points at `daemon restart` and the macOS foreground window mode. Non-closed navigation failures and the page-creation paths are untouched. This is the error-mapping half of agentrhq#225. The macOS background `open -g` launch that self-terminates is a CloakBrowser/LaunchServices issue and is not fixed here.
Contributor
🟠 Maintainer review suggested — low confidenceThe automated review could not reach a fully supported conclusion. This review is advisory and does not block merging. |
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.
Addresses the error-mapping half of #225 (suggested fix 2).
Cause
On CloakBrowser's free tier a second concurrent profile exits with code 76. Playwright surfaces the dead target as
Target page, context or browser has been closed, which is also what an externally closed browser, a crash, and a never-started browser all produce. Nothing in the repo matched exit code 76, so the licensing cap arrived as a generic navigation failure:The reporter traced the daemon, profile multiplexing, and CDP end to end before finding the cap — the message pointed nowhere.
Fix
Two mappings onto the
BrowserConnectError/'profile-disconnected'kind that already exists for this:launchProfileRuntimechecks the launch failure for exit code 76 first and reports the session limit andCLOAKBROWSER_LICENSE_KEY.Another live profile is the one cause that can actually be checked, so it picks the hint rather than being asserted blindly:
webcmd daemon restart, andWEBCMD_WINDOW=foregroundon macOS.Deliberately unchanged: the retry ladder itself, non-closed navigation failures (still rethrown by identity), and the page-creation paths —
newPage/getPageacquisition still reject with the raw text that existing tests pin.Not fixed here
Suggested fix 1, the macOS background
open -g -ninstance being sudden-terminated by LaunchServices, is a CloakBrowser/macOS problem I cannot reproduce or verify on Windows. This PR only makes its symptom legible: a browser that dies on its own now reports a disconnect with a restart hint instead of a navigation error.Tests
src/browser/runtime/local-cloak/session-manager.test.ts:Process exited with code 76producesBROWSER_CONNECT/profile-disconnected, names the license key, and preserves the original text;peerprofile alive, a repeatedly closed navigation onactornamespeerand the one-browser-at-a-time cap (the issue's concurrent-profile repro);daemon restart;net::ERR_NAME_NOT_RESOLVEDis still rejected by identity, with no extra launch.npx vitest run --project unit src/browser— 47 files, 752 passed, 2 skipped.npm run typecheckandnpm run check:typed-error-lintclean.