Skip to content

Accept js-debug target-closed reply to Blazor hosted-global Page.close - #21938

Merged
David Fowler (davidfowl) merged 1 commit into
mainfrom
aspireagent/blazor-natural-close-target-closed-reply
Nov 10, 2026
Merged

David Fowler (davidfowl) merged 1 commit into
mainfrom
aspireagent/blazor-natural-close-target-closed-reply

Conversation

@davidfowl

@davidfowl David Fowler (davidfowl) commented Nov 8, 2026 •

Copy link
Copy Markdown
Collaborator

Description

What failed: [vscode] Aspire Blazor browser debugger E2E > hits a managed breakpoint for hosted-global in VS Code extension E2E (Windows, browser-debugger), on main in run 42413925421 (job) and on a PR branch in run 42312596518 (job). The test reported only the masked bridge error Failed to apply E2E control revision …: E2E control command failed.

Why: hosted-global is the only Blazor scenario that uses closeMode: 'natural'. The proof continues the breakpoint, asks js-debug for its CDP proxy and sends Page.close over that socket. The js-debug traces in both failing runs' diagnostics artifacts (blazor-debugadapter-*.json, proxyActivity) show the page target detaching before the browser answered. js-debug v1.117.0's CDPSession._onClose (connection.ts#L385-L388) rejects the pending call with setCause(0, 'Connection is closed'), and the proxy (sendOrDie) relays it to the client as {"id":1,"error":{"code":0,"message":"Connection is closed"}}, keeping the proxy socket open. Passing runs get {"id":1,"result":{}}. closeBrowserPageThroughCdp already accepted a socket close after Page.close as "target gone", but treated this equivalent error reply as Browser CDP Page.close failed, which fails the proof even though the page, Mono and root sessions then terminate normally (they do in both traces).

Fix: closeBrowserPageThroughCdp now treats the js-debug target-closed reply (code === 0 && message === 'Connection is closed') the same as the socket-close case. This doesn't weaken the proof: the caller still requires every proof session (root, browser, managed) to terminate and debug-in-browser to return to Enabled. Any other Page.close error (e.g. -32601 Method not found) still fails.

Regression tests (extension/src/test/e2eStateFileBridge.test.ts, run against the real executeE2eControlCommand product path):

  • accepts target disconnection (target-closed reply) during Page.close only after all proof sessions terminate: the CI failure, which fails without the fix with the exact CI error Browser CDP Page.close failed: {"code":0,"message":"Connection is closed"}.
  • rejects a target-closed Page.close reply while a proof session remains active: shows the reply is not a bypass, because the proof still fails if the managed session stays alive.
  • The existing socket-close case is kept, parametrized alongside the new one.

Dedupe: no open issue or PR covers hosted-global. #21912 covers a different browser-debugger failure (the maps managed Edge debugging before-all hook CLI --version probe), and none of the AspireAgent PRs #21911–#21932 touch this test. Tracker: #21600.

Confidence

Paired local runs of e2eStateFileBridge.test.js under VS Code 1.131.0 (vscode-test, xvfb), same machine and commit, toggling only the product change:

runs green per-run result
before (fix reverted, new tests kept) 0/10 61 passing, 2 failing (the two new tests, with the CI error)
after 10/10 63 passing, 0 failing

yarn lint and yarn compile-tests pass. This is a test-harness change only (extension/src/testing), so there's no product behavior change and no E2E behavior evidence beyond the CI browser-debugger shards on this PR.

Failure stats (14d, attempt 1)

Window 2026-10-25 12:00 → 2026-11-08 12:00 UTC, ci.yml, attempt-1 jobs only. The denominator is decided attempt-1 runs (same definition as #21600). Hits are verified from each failed VS Code extension E2E (Windows, browser-debugger) job's mocha failure line (48 failed jobs scanned over 30d).

  • This signature (hits a managed breakpoint for hosted-global → Page.close target-closed reply): 3/1157 decided runs, 2 main / 1 PR (main 2/160, PR 1/997).
  • Any hosted-global failure: 4/1157. The extra one (run 40728167754) is a different cause, Timed out after 300000ms waiting for browser navigation to 'counter', which this PR does not claim to fix.
  • 30d main: 2 verified hits (both are in the 14d window). Six older or other main browser-debugger failures had expired or unavailable logs and could not be classified.
  • The two newest failures show only the masked E2E control command failed.; the js-debug traces in their diagnostics artifacts show the {"code":0,"message":"Connection is closed"} proxy reply. The 10-28 main failure predates the masking and prints the exact error.
Run Date (UTC) Branch Job Error
42413925421 11-07 21:02 main 128531739772 masked; trace shows target-closed reply
42312596518 11-06 23:32 PR (eerhardt-dashboard-authorize-anonymous-pages) 128225566096 masked; trace shows target-closed reply
40606196498 10-28 00:02 main 122561450397 Browser CDP Page.close failed: {"code":0,"message":"Connection is closed"}
40728167754 10-28 16:39 PR (native-bundle-continuation) 122971965889 different cause: navigation timeout (not addressed)

Verdict

STRONG: the failure was reproduced deterministically through the product code path, and the before-fix run fails with the exact CI error string (0/10 → 10/10). js-debug traces from both recent failures and the unmasked 10-28 main error point to the same cause. The frequency is low (3/1157), so CI alone will take time to confirm the absence of hits.

This PR's own CI (head bbb5a79f) was green on both browser-debugger shards on attempt 1. The attempt-1 rerun was only for the unrelated tree-actions flake (#21796, fix in #21914).

How we stop this recurring: CDP proxy transport outcomes after Page.close (socket close or js-debug's target-closed reply) are now classified in one place, isCdpProxyTargetClosedError, with unit tests pinning both forms. The proof's real gate stays session termination plus command reset, so future js-debug transport variations can't silently mask a real leak.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No

🤖 Posted by AspireAgent (AI Agent)

When the hosted-global Blazor proof closes the browser page through the
js-debug CDP proxy, the page target can detach before Page.close is
answered. js-debug then rejects the pending call with
{"code":0,"message":"Connection is closed"} and relays it to the proxy
client. Treat that reply like the existing socket-close case; the caller
still requires every proof session to terminate and the debug-in-browser
command to reset.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@davidfowl David Fowler (davidfowl) added area-vscode-extension agent:working An AI agent is actively working on this issue or PR labels Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21938

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21938"

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Tests selector

0 / 101 PR test projects · 2 PR jobs, from 2 changed files.

Selected PR test projects (0 / 101)

none — no PR-gated .NET test projects run for this change.

Selected PR jobs (2)

extension-e2e, extension-unit


How these were chosen — grouped by what changed

Job reasons

Job Triggered by
extension-e2e extension/src/test/e2eStateFileBridge.test.ts, extension/src/testing/e2eStateFileBridge.ts
extension-unit extension/src/test/e2eStateFileBridge.test.ts, extension/src/testing/e2eStateFileBridge.ts

Selection computed for commit bbb5a79.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues block the targeted debugger-disconnection handling change.

No open issues 🎉

What changed in this PR

This PR addresses a Blazor hosted-global debugger E2E flake in the Aspire VS Code extension’s test harness. It accepts js-debug’s exact target-closed reply to Page.close while preserving session-termination and command-reset requirements.

Changes:

  • Recognizes code: 0 with message: 'Connection is closed' as target disconnection; other errors still fail.
  • Extends regression tests to cover both disconnection forms and rejection when a managed session remains active.
File Description
extension/​src/​testing/​e2eStateFileBridge.ts Handles the target-closed CDP reply and documents its meaning.
extension/​src/​test/​e2eStateFileBridge.test.ts Tests accepted disconnections, cleanup, and active-session rejection.

Review effort: Balanced

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Findings: 0 correctness, 0 security, and 0 test coverage issues.

@davidfowl
David Fowler (davidfowl) merged commit 2d5b1bd into main Nov 10, 2026
196 of 199 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 17.1 milestone Nov 10, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

✅ No documentation update needed.

docs_optional → internal_refactor (proven false positive). Triggered signal: pr_body_has_cli_flag_mention — evidence is only a --version mention in the PR body, about a CI hook probe. Changed files are extension/src/testing/e2eStateFileBridge.ts and its test, which are E2E test-harness code. They change how the harness handles a js-debug target-closed reply to Page.close. There is no user-facing surface change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants