Blazor debugging captures unrelated debug sessions and terminates them together
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 72/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript, vscode
- 领域
- devtools
调研方向
阅读 src/razor/src/blazorDebug/blazorDebugConfigurationProvider.ts,尤其是第 73–142 行和第 795–800 行,并跟踪调试会话的启动和终止处理程序。为 Blazor 调试期间启动的无关 Node 会话在两个 teardown 方向上添加回归覆盖;完成标准是这些会话保持独立,而 Blazor 所有的会话仍然级联。
由索引模型根据 Issue 内容生成。
描述
Summary
While a Blazor WebAssembly debugging session is active, the C# extension captures unrelated debug sessions that start afterward. Closing the Blazor browser then terminates those unrelated sessions. The reverse also happens: stopping an unrelated session started after Blazor attachment terminates the Blazor browser and managed debugger.
Reproduced with the actual Marketplace C# extension, a real Edge browser rendering a Blazor WebAssembly app, monovsdbg_wasm, and independent Node debug processes. No provider mocks, replacement debug adapters, or Aspire extension code were used. Both directions reproduced in two complete runs.
Sessions started before Blazor attachment are unaffected: a preexisting Node session remained active and its process heartbeat continued advancing after both teardown scenarios.
Environment data
- Windows ARM64, OS build 10.0.26200.
- VS Code 1.137.0, commit
645f29cc3176500b4b5762ba887cf2a7f0ffdf2c. ms-dotnettools.csharp2.148.23, Marketplace win32-arm64 VSIX.- C# Dev Kit 3.20.207; .NET Install Tool 3.1.0.
- .NET SDK 10.0.112; standalone Blazor WebAssembly template targeting
net10.0, WebAssembly/DevServer packages 10.0.12. - Edge 152.0.4191.62, headless.
- Node 25.9.0 for the independent debuggees; extension-host Node 24.18.1.
- Execution used an isolated VS Code Extension Development Host with dedicated user-data and extension directories. Normal installed extensions/settings were not modified.
Inspected source: tag v2.148.23-prerelease, commit 2f5806a9f39575bfaf4ca16445f420440a43e050.
Steps to reproduce
The following sequence was executed through the VS Code debug API in the isolated Extension Development Host. All root sessions were launched independently: no compound launch, parent-session argument, or explicit cascade setting was assigned to either Node configuration.
- Create and run a standalone .NET 10 Blazor WebAssembly app (
dotnet new blazorwasm). Open the client folder in VS Code and wait for C#/Razor initialization. - Start an independent Node debug session named
preexisting. Its program writes a heartbeat every 200 ms, allowing survival to be checked independently of VS Code's session list. - Start Blazor debugging against the already-running app using the configuration below. Wait for the actual browser/page sessions and
monovsdbg_wasm, and for the page to render. - Start another independent Node debug session named
unrelated-after, running the same heartbeat program. - Scenario A: close only the Blazor browser. In the executed reproduction, this was a CDP
Browser.closerequest to the browser's real debugger endpoint, not a VS Code stop-all operation. - Observe that
unrelated-afteralso terminates, although it has no relationship to the Blazor app.preexistingremains active and its heartbeat continues. - Repeat steps 2–4 with fresh sessions. Scenario B: call
vscode.debug.stopDebugging(unrelatedAfterSession)for only the later Node root session. - Observe that the Blazor browser/page and
monovsdbg_wasmalso terminate. Again,preexistingsurvives and continues executing.
Blazor configuration used by the reproduction (paths and URL below are placeholders):
{
type: "blazorwasm",
request: "attach",
name: "blazor-browser",
projectPath: "<absolute path to BlazorClient.csproj>",
cwd: "<absolute path to BlazorClient>",
url: "<running Blazor server URL>",
browser: "edge",
webRoot: "<absolute path to BlazorClient/wwwroot>",
browserConfig: {
userDataDir: "<isolated browser profile>",
runtimeArgs: [
"--headless=new",
"--no-first-run",
"--no-default-browser-check"
],
trace: true
}
}
The independent sessions use ordinary pwa-node configurations with request: "launch", distinct names, program pointing at a long-running Node script, and console: "internalConsole". They are launched with vscode.debug.startDebugging(undefined, configuration) and no third argument. A minimal long-running program is:
setInterval(() => console.log(`heartbeat ${Date.now()}`), 200);
The executed driver additionally writes heartbeats to separate files and asserts that the preexisting process keeps executing after teardown. Browser rendering was confirmed through the page session's DAP evaluate request: document.body.innerText.includes("Hello, world!") returned true before starting the unrelated session.
Expected behavior
Only debug sessions owned by the same Blazor launch should participate in its cascade termination. An independent session must remain independent regardless of whether it starts before or after Blazor attachment.
- Closing the Blazor browser should not stop an unrelated Node session.
- Stopping that Node session should not stop Blazor debugging.
Actual behavior
| Trigger | Blazor browser/managed sessions | Unrelated session started after attach | Preexisting session |
|---|---|---|---|
CDP Browser.close |
Terminated | Unexpectedly terminated | Survived; heartbeat advanced |
Stop only unrelated-after |
Unexpectedly terminated | Terminated as requested | Survived; heartbeat advanced |
Logs / runtime evidence
Condensed from the successful onDidStartDebugSession / onDidTerminateDebugSession event trace on September 11, 2026 (UTC). The driver observes events; it does not stop any additional sessions until after recording each scenario result.
15:35:40.153 started preexisting (pwa-node)
15:35:40.958 requested Blazor attach
15:35:44.969 started Wasm Managed Debugger (monovsdbg_wasm)
15:35:48.852 started Blazor browser (pwa-msedge)
15:35:56.335 Blazor DOM rendering confirmed
15:35:56.846 started unrelated-after (pwa-node)
15:35:57.514 requested CDP Browser.close
15:35:57.885 browser page terminated
15:35:58.836 managed debugger terminated
15:35:58.863 browser root terminated
15:36:02.642 unrelated-after root terminated
15:36:03.007 result: preexisting survived; heartbeat advanced
15:36:06.129 requested fresh Blazor attach (after fresh preexisting Node start)
15:36:08.897 started Wasm Managed Debugger (monovsdbg_wasm)
15:36:13.947 started Blazor browser (pwa-msedge)
15:36:22.845 Blazor DOM rendering confirmed
15:36:24.028 started unrelated-after (pwa-node)
15:36:24.900 requested stopDebugging(unrelatedAfterSession) only
15:36:25.720 unrelated-after root terminated
15:36:25.772 browser page terminated
15:36:26.594 managed debugger terminated
15:36:26.621 browser root terminated
15:36:26.835 result: preexisting survived; heartbeat advanced
An earlier complete run reproduced both directions at 15:28 UTC as well. Raw C# diagnostics contain machine-local paths and are omitted here; the structured trace above contains the directly observed lifecycle evidence.
Code gap
The observed timing matches the static tracking in BlazorDebugConfigurationProvider:
- Lines 73–98: one static tracking flag/set/map;
onDidStartDebugSessioncaptures every session while tracking is enabled, with no ownership or launch-group filter. - Lines 101–116: when any captured session terminates, the handler calls
stopDebuggingon every captured peer. - Lines 136–142:
resolveDebugConfigurationclears the collections and enables tracking. Tracking remains enabled until a captured session terminates, rather than being scoped to sessions owned by this launch. - Lines 795–800:
tryToUseVSDbgForMonoenables the same global state.
Please scope cascade tracking to the sessions owned by each Blazor launch, with regression coverage for unrelated sessions started during an active Blazor session in both termination directions.
Additional context
This was identified while reviewing the new managed-browser integration in microsoft/aspire#20001, which calls the high-level blazorwasm attach provider. The reproduction deliberately omits Aspire to isolate the upstream behavior.
This is distinct from #7864 (processes left running/port conflicts after closing debugging) and #7386 (an older C# Dev Kit/Aspire shutdown issue).
The successful reproduction used a headless browser and VS Code API automation, not UI-click automation. It confirms real browser rendering and managed-debugger lifetime, but does not assert a managed C# breakpoint or cover two simultaneous Blazor launch groups. All reproduction-owned processes were cleaned up afterward.
- 主要语言
- TypeScript
- 星标
- 3.1k
- 派生
- 736
- 平均合并
- 21 小时 21 分钟
- 30 天内合并 PR
- 42
环境准备
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
dotnet/vscode-csharp 的其他 Issue
-
Infrastructure Test
难度 2/5 1-3 小时 新手友好度 70/100
dotnet/vscode-csharp#9791 · 1 条评论 ·
维护者通常 1 天内回复
-
C# crash未关闭Bug C#DK Needs More Info Reliability Remote Extensions Roslyn LSP
难度 4/5 3-5 天 新手友好度 25/100
dotnet/vscode-csharp#9807 · 1 条评论 ·
维护者通常 1 天内回复
-
Editor-Formatting Resolved-Configuration Issue
难度 3/5 1-2 天 新手友好度 65/100
dotnet/vscode-csharp#9804 · 6 条评论 ·
维护者通常 1 天内回复
-
Debugger untriaged
难度 3/5 1-2 天 新手友好度 68/100
dotnet/vscode-csharp#9802 ·
维护者通常 1 天内回复
-
untriaged
难度 4/5 3-5 天 新手友好度 58/100
dotnet/vscode-csharp#9787 · 6 条评论 ·
维护者通常 1 天内回复
查看 dotnet/vscode-csharp 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 88/100
openedx/frontend-app-authoring#3274 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
-
area/documentation status/need-triage
难度 1/5 1 小时以内 新手友好度 95/100
google-gemini/gemini-cli#29548 ·
维护者通常 1 天内回复
-
sdk-typescript vector-store
难度 2/5 半天 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复