Repository navigation
fix(cli): retry retained browser scenario cleanup - #1773
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 83351cfdfb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } catch (cause: unknown) { | ||
| // Failed captures already retain their primary error and partial | ||
| // observations. A cleanup retry must not replace that outcome. | ||
| if (result?.ok) |
There was a problem hiding this comment.
Keep ownership when the final cleanup retry fails
If provider.close() also rejects, this branch suppresses that rejection whenever capture returned an error. The real Playwright provider still owns the callback in #pendingCleanup, but this one-shot command then drops the only provider reference and has no later shutdown hook; for example, a browser/profile that succeeds only on the third close—as in the persistent-failure fixture, whose manual cleanup masks production behavior—remains running or on disk. Keep the owner reachable for another cleanup attempt instead of returning here.
AGENTS.md reference: AGENTS.md:L17-L17
Useful? React with 👍 / 👎.
| | undefined; | ||
| try { | ||
| result = await captureBrowserScenario(provider, scenario.data); | ||
| return result.ok ? result.value : cliError(result.error); |
There was a problem hiding this comment.
Replace the stale cleanup result after retry success
When the scenario's first session.close() fails but the retained callback succeeds in provider.close()—the new RetrySession test with one injected failure exercises exactly this path—the return value remains the original cleanup_incomplete projection. The CLI therefore exits with failure and reports browser_transport and browser_profile as retained even though the retry released both; reconcile the outcome after a successful retry rather than returning stale cleanup uncertainty.
AGENTS.md reference: AGENTS.md:L17-L17
Useful? React with 👍 / 👎.
The one-shot browser scenario CLI previously discarded its provider after returning capture results, leaving the real Playwright provider's retained cleanup callback without a retry. Attempt optional provider close before the command finishes, including failed and unexpectedly thrown captures.
Preserve the primary capture error and partial observations when shutdown also fails. If capture succeeded but shutdown fails, report a typed cleanup failure and retain the completed, authenticated Evidence. Persistent failures remain reported as incomplete cleanup; one retry does not establish eventual recovery.
Validation:
6d5d71fathrough the registered Incur CLI, real Playwright scenario provider and cleanup owner: error/partial observation assertions passed, but provider close was called zero times.40b37aeethrough the source production CLI/provider boundary; the same zero-close assertion fails. The private reproduction worktree was removed.The boundary fixtures inject provider session failures without creating live Chromium processes or profiles. This does not claim live-browser verification or fix a specific earlier real-provider timeout.
Closes #1771.