Repository navigation
fix(browser): report cancellation after cleanup and source-map abort - #2893
Conversation
An interrupt during CDP cleanup could still publish the captured page, and a source-map download abort was wrapped as a provider failure. Both now return AnalysisCancelledError for the requested operation.
The empty DSH_HOME fix also changed Devin's declared format to "devin", which is not a configuration format and stops the typecheck. Devin still writes mcp_config.json.
The added interrupt cases made the existing lifecycle suite exceed the function-length lint limit.
The inventory MCP test imported join twice, which fails lint on current main.
noUncheckedIndexedAccess treats the unlabeled pair list as an open array, so the directory passed to join was string or undefined.
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: 82bcf0814d
ℹ️ 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".
| : isAbortError(cause) | ||
| ? new AnalysisCancelledError(operation, { cause }) |
There was a problem hiding this comment.
Use the signal state to classify source-map cancellation
When a caller cancels source-map fetching with a custom reason, such as controller.abort(new Error("cancelled")), fetchWebSourceMaps rethrows that reason verbatim, so this name-based check fails and wraps the cancellation in ProviderAdapterError. AbortSignal.reason may be any value, not only the default AbortError; therefore SDK/MCP callers using custom reasons still receive execution_failure instead of the intended tagged cancellation. Pass the signal into this classification or check options.signal.aborted in analyzeBundle's catch path.
AGENTS.md reference: AGENTS.md:L29-L29
Useful? React with 👍 / 👎.
[Low impact] The current test-only changes appear safe to merge. SummaryThe current PR diff adds tests and fixture support. The production cancellation changes are already in the target branch.
Reviews (7) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile |
# Conflicts: # src/browser/CdpBrowserProvider.ts # tests/boundary/cli/clientProfileLifecycle.test.ts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a742936108
ℹ️ 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".
| if (options.signal?.aborted === true) | ||
| throw new AnalysisCancelledError(operation); |
There was a problem hiding this comment.
Update the existing cleanup-cancellation regression
When the full boundary suite runs, the unchanged tests/boundary/browser/cdpCleanupCancellation.test.ts case “releases cleanup when cancellation arrives after capture completes” still aborts during Page.disable and asserts result.ok is true. This new post-cleanup throw deterministically turns that same call into an error result, so npm run check:pr will fail even though the newly added focused tests pass. Update that regression to expect cancellation while retaining its detach and socket-cleanup assertions.
AGENTS.md reference: AGENTS.md:L77-L77
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 49ada44d9b
ℹ️ 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".
| if (options.signal?.aborted === true) | ||
| throw new AnalysisCancelledError(operation); |
There was a problem hiding this comment.
Preserve work failures when cleanup is cancelled
When the work callback has already thrown—for example, because the target changed or CDP returned a protocol error—and the caller aborts while a *.disable cleanup command is pending, throwing from this finally block replaces that pending error under JavaScript semantics. The result reports only cancellation and discards the actual operation failure; retain the primary error, at least as the cancellation cause, rather than unconditionally replacing it.
AGENTS.md reference: AGENTS.md:L29-L29
Useful? React with 👍 / 👎.
|
CI-fix track: this conflicts with main's newer design, so it needs your call. I didn't push anything.
If you keep the service-layer design, this PR is superseded except possibly for its fixture additions. If you want provider-level cancellation, main's service checks and `cdpCleanupCancellation` expectation would change instead. The failing Static checks and `productCatalog` jobs on this PR came from main's state at the time. |
Complete owned teardown before deciding whether a successful observation can be published. Classify an exactly propagated source-map abort reason as cancellation while preserving unrelated failures. Validation: all four cleanup/cancellation boundary tests pass, retaining detach, socket and target-liveness assertions. Based on #2893.
|
Heads up: main covers this in its own way in ad9e22d. The code is in 🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
# Conflicts: # src/browser/CdpBrowserProvider.ts
|
Conflict-sweep note: merged latest |
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
An interrupt that arrives while a CDP session is closing could still publish the captured page, session, WebMCP discovery, or screenshot. An interrupt during an approved source-map download was reported as a provider failure instead of cancellation. Both now return
AnalysisCancelledErrorfor the operation the caller requested.This branch also includes the current
maintypecheck and lint repairs from the companion check-restoration change, so this pull request can passcheck:faston its own.Problem and expected behavior
inspect-web-page, bundle analysis, session observation, WebMCP discovery, and screenshot capture awaitcloseCdpTargetSessionafter the result is already built. Cleanup notices an aborted signal and closes the socket, then the caller publishes success.fetchWebSourceMapsthrows the abort reason. That reason is a DOMException namedAbortError, soCdpBrowserProviderwrapped it asProviderAdapterErrorand the CLI reportedexecution_failurewhile still exiting 130 or 143.After this change, an abort during cleanup or during a source-map download returns
AnalysisCancelledErrorforinspect_web_page,analyze_web_bundle,observe_web_session,discover_webmcp_tools, orcapture_web_screenshot.Change and scope
The browser provider owns this classification. After cleanup, an aborted caller signal replaces a result that was already built.
providerErrormaps anAbortErrortoAnalysisCancelledErrorbefore it can become a provider-adapter failure. Deadline failures staySourceMapDeadlineErrorand are not treated as caller cancellation.Contribution scope fit: ordinary fix inside the existing passive CDP provider. Maintainer scope decision: not applicable. This does not add target execution, injection, or mutation.
Contract and boundary impact
CdpBrowserProviderafter session cleanup and at provider error classification.AnalysisCancelledError. No new tool or argument.Expected effects:
The network contact is the existing approved source-map fetch. Cancellation stops that fetch.
Evidence and regression coverage
Network.disableor during the source-map response still produced a successful result orProviderAdapterError.AnalysisCancelledErrortocode: "cancelled"now do so for these two windows. The CLI signal wrapper in fix(cli): honor SIGINT/SIGTERM in browser and JS-runtime commands #2879 is unchanged here.Validation performed
npm run test:focused -- tests/boundary/browser/cdpBrowserProvider.lifecycle_failures.test.ts— 14 passed.npm run check:fast— typecheck and lint passed.Compatibility, safety, and release
No breaking contract change. Operations that previously returned success after an interrupt during cleanup now return cancellation. That matches the signal the caller already raised.