Skip to content

fix(cli): retry retained browser scenario cleanup - #1773

Merged
N0zoM1z0 merged 1 commit into
mainfrom
fix/browser-cli-cleanup-retry-1771
Oct 11, 2026
Merged

N0zoM1z0 merged 1 commit into
mainfrom
fix/browser-cli-cleanup-retry-1771

Conversation

@N0zoM1z0

@N0zoM1z0 N0zoM1z0 commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

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:

  • Reproduced on exact main 6d5d71fa through the registered Incur CLI, real Playwright scenario provider and cleanup owner: error/partial observation assertions passed, but provider close was called zero times.
  • Repeated the missing-close reproduction on newer main 40b37aee through the source production CLI/provider boundary; the same zero-close assertion fails. The private reproduction worktree was removed.
  • Five CLI boundary regressions plus 14 existing provider tests passed: transient and persistent cleanup failure, completed Evidence retention, nested cancellation diagnostics and thrown-error precedence. Existing provider tests retain actual AbortSignal coverage.
  • Fresh runtime compile, full single-threaded typecheck, lint/module boundaries, changed-file formatting and architecture guards passed under the 2 GiB/90-second local guardian.

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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-11T08:39:25.699430Z 83351cf PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +61 to +64
} catch (cause: unknown) {
// Failed captures already retain their primary error and partial
// observations. A cleanup retry must not replace that outcome.
if (result?.ok)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@N0zoM1z0
N0zoM1z0 merged commit 4daea94 into main Oct 11, 2026
31 checks passed
@N0zoM1z0
N0zoM1z0 deleted the fix/browser-cli-cleanup-retry-1771 branch October 11, 2026 08:51
@morluto morluto mentioned this pull request Oct 13, 2026
3 tasks done
@morluto morluto added bug Something isn't working area: cli CLI adapter and one-shot commands labels Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli CLI adapter and one-shot commands bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(cli): retry retained browser scenario cleanup before exit

2 participants