fix(extension): retry console capture when a domain enable fails#39
Open
hobostay wants to merge 1 commit into
Open
fix(extension): retry console capture when a domain enable fails#39hobostay wants to merge 1 commit into
hobostay wants to merge 1 commit into
Conversation
`enableConsoleDomains` marked the tab in `consoleDomainsAttemptedTabs` before issuing `Runtime.enable`/`Log.enable` and swallowed any errors, so a transient failure (e.g. a restricted page during attach) permanently disabled console capture for that tab: every later `ensureConsoleCapture` was a no-op and the agent silently got an empty console buffer with no indication that capture was broken. This was inconsistent with `enableNetworkDomain`, which records the tab only after `Network.enable` succeeds (and is explicitly tested as "retries and surfaces failures"). Bring `enableConsoleDomains` in line: mark the tab only after both domains enable successfully, so a later `ensureConsoleCapture` can recover from a transient failure. Renamed the flag `consoleDomainsAttemptedTabs` -> `consoleDomainsEnabledTabs` to match `networkDomainsEnabledTabs` and reflect the new semantics. Attach remains best-effort (it still succeeds when a domain can't be enabled). Adds a regression test asserting `ensureConsoleCapture` retries after a failed enable; it fails (no retry) on the previous code. Co-Authored-By: Claude <noreply@anthropic.com>
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
enableConsoleDomainsmarked the tab as attempted before issuingRuntime.enable/Log.enableand swallowed any error:So a transient failure (e.g. a restricted page during attach) permanently disabled console capture for that tab: every later
ensureConsoleCapturehit the earlyreturnand the agent silently got an empty console buffer, with no indication capture was broken — for the tab's whole lifetime.This is inconsistent with
enableNetworkDomainright next to it, which records the tab only afterNetwork.enablesucceeds and is explicitly tested as "retries and surfaces failures" (chromium-cdp.test.ts).Fix
Record the tab only after both domains enable successfully, so a later
ensureConsoleCapturecan recover from a transient failure — mirroringenableNetworkDomainexactly:Also renamed the flag
consoleDomainsAttemptedTabs→consoleDomainsEnabledTabsto matchnetworkDomainsEnabledTabsand reflect the new (correct) semantics.Attach stays best-effort: it still succeeds when a domain can't be enabled (console/network are best-effort during attach). The change only affects whether capture can be retried later.
Test
Log.enablefails during attach, thenensureConsoleCaptureis shown to retry both domains (2 → 4 enable calls). This test fails on the previous code (stays at 2, no retry).Validation
Frontend CI gates run locally against this branch:
pnpm ext:test— 428 passed ✅pnpm --filter @browser-skill/extension compile(tsc --noEmit) ✅pnpm lint(biome + stylelint) ✅pnpm ext:build✅🤖 Generated with Claude Code