Skip to content

fix(cli): await browser scenario cleanup on interrupts - #1780

Merged
N0zoM1z0 merged 1 commit into
mainfrom
fix/browser-scenario-cli-interrupt-cleanup-20261011
Oct 11, 2026
Merged

N0zoM1z0 merged 1 commit into
mainfrom
fix/browser-scenario-cli-interrupt-cleanup-20261011

Conversation

@N0zoM1z0

Copy link
Copy Markdown
Collaborator

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 914ba833 exits 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 withCommandCancellation and pass its signal to captureBrowserScenario. 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

  • Semantic owner and earliest changed stage: one-shot CLI signal boundary.
  • CLI and MCP/tool-catalog contract: CLI interrupt behavior corrected; schemas unchanged.
  • Provider, bridge, target-format, or platform compatibility: existing browser provider cancellation reused; POSIX signal regression skips Windows.
  • Evidence, artifact, provenance, or reconstruction contract: interrupted captures retain authenticated Evidence with incomplete capture accounting and cancelled steps.
  • Process execution, authorization, cleanup, or containment impact: owned provider cleanup is awaited before command completion.
  • Generated metadata, package, or installation impact: none.

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 914ba833 with 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

  • Fresh single-threaded compile, 21 focused tests (new subprocess tests, existing CLI cleanup tests and provider tests), and independent public interrupt probe: passed.
  • Full single-threaded typecheck, lint/module boundaries, changed-file format check and architecture guards: passed.
  • Rebuilt the committed source and reran 21 tests plus both public interrupt probes: passed.
  • All steps supervised within 2 GiB process-family RSS and 90-second limits. Used explicit single-threaded checks rather than the default threaded pre-push hook.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: Linux CLI/OS signals; controlled browser transport as described above.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: explicit provider ownership and existing cleanup paths retained; test child processes owned by the shared registry.

Review checklist

  • Concrete problem; one focused Conventional Commit outcome.
  • Related issue linked; existing open fixes searched.
  • Regression fails on base and verifies observable behavior after the fix.
  • Contracts and generated metadata need no changes.
  • Representative CLI behavior and verification scope stated.
  • Final diff reviewed for unrelated changes and unsupported claims.

@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-11T09:21:05.048852Z b1329c1 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: 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".

Comment on lines +58 to +60
result = await captureBrowserScenario(provider, scenario.data, {
signal,
});

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

@N0zoM1z0
N0zoM1z0 merged commit aaeadf2 into main Oct 11, 2026
31 checks passed
@N0zoM1z0
N0zoM1z0 deleted the fix/browser-scenario-cli-interrupt-cleanup-20261011 branch October 11, 2026 09:34
@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.

2 participants