Repository navigation
fix(cli): await browser scenario cleanup on interrupts - #1780
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: b1329c1fec
ℹ️ 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".
| result = await captureBrowserScenario(provider, scenario.data, { | ||
| signal, | ||
| }); |
There was a problem hiding this comment.
Keep browser startup cancellable after trapping signals
When SIGINT or SIGTERM arrives while launch mode is awaiting launchPersistentContext, the newly installed process listener suppresses Node's default signal exit, but forwarding this signal cannot unblock that await: openPlaywrightScenarioBrowser calls launchPersistentContext without an abort boundary and explicitly sets its timeout to 0 (src/browser/PlaywrightScenarioBrowser.ts). If browser startup stalls, the CLI therefore never reaches its cancellation checks or cleanup and cannot exit with 130/143. Make the opening phase abort-aware while retaining ownership of any browser that opens late, and cover an interrupt during startup rather than only during an action.
Useful? React with 👍 / 👎.
Summary
When interrupted during a browser scenario, the CLI now waits for provider cleanup and returns retained observations with exit code 130 for SIGINT or 143 for SIGTERM. Refs #1771; GitHub issue/PR searches found no open fix for this interrupt path.
Problem and expected behavior
Fresh main
914ba833exits immediately on either OS signal while an action is active: no AbortSignal reaches the provider, cleanup callbacks are skipped, and stdout is empty. The command should translate an interrupt into cancellation, await its owned cleanup, and preserve completed and cancelled steps.Change and scope
Wrap command logging with the existing
withCommandCancellationand pass its signal tocaptureBrowserScenario. Keeping cancellation outside logging preserves conventional interrupt exit codes after error handling. Existing provider cleanup retries and ownership rules continue to apply.Contract and boundary impact
Evidence and regression coverage
Added two real CLI subprocess tests sending SIGINT/SIGTERM after a controlled session starts its action. They assert normal exit 130/143, signal delivery, cleanup callbacks, authenticated stdout Evidence, completed start and cancelled action, and incomplete capture status.
Both tests fail against freshly compiled main
914ba833with direct signal termination. An independent public-CLI probe also confirms skipped cleanup callbacks and empty output on that base.After the change, the independent probe returns authenticated Evidence on both interrupts and confirms cleanup callbacks ran.
Scope: real OS signals and public compiled CLI, real Playwright provider and cleanup owner, controlled session. No Chromium process or browser profile is created. Windows interrupt behavior remains unverified.
Observed, derived, and inferred claims remain distinguishable.
Artifact identity, source provenance, and failed attempts remain preserved.
Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.
Validation performed
Compatibility, safety, and release
Review checklist