microsoft / microsoft/vscode

Webview can go blank when an earlier mount finishes after a remount

Open
#335,908 0 comments 0 reactions 1 assignee Claimed by @kycutler View on GitHub
triage-needed
Dominant language
TypeScript
Stars
193k
Forks
42.4k
PR merge metrics
PR metrics pending

Description

I’m seeing intermittent blank MCP App views in the main Chat panel on Windows, with VS Code 1.135.0 (`08d4889f9ec4a1685d257b9b95de036c8e1ce1e5`). The tool calls and resource reads succeed, but some views never get an inner iframe. Reload Window restores them.

I found a race in `WebviewElement.mountTo` that reproduces the blank view:

1. Start a mount and leave its `parentOriginHash` promise pending.
2. Remount the same webview and let the second hash finish.
3. Let the first hash finish after the second view has connected.

The first completion still calls `_initElement`, resetting the iframe. The webview retains a message port, but the replacement frame stays blank.

I tested this in an isolated VS Code window by delaying the first hash result by 350ms. Ignoring a hash completion when its promise is no longer the current mount promise kept all three test views visible across three repeated rounds. The encoded origin needs the same check, so an older completion cannot overwrite it either.

[Small source patch and standalone regression check](https://github.com/absolutejs/mcp/tree/2c4bb1f/canary/vscode). The check executes `mountTo` extracted from the upstream TypeScript file: both obsolete-completion cases fail before the patch and pass afterward. It is not the full VS Code test suite. The same mount method is present on current main.

This may be related to #331140, but I reproduced this in the main Chat panel, without an auxiliary window. I haven’t established that this race explains every blank MCP App report.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.