Extension host crash: Webview is disposed thrown from setTimeout in extension.js (v2.1.141)

Status Closed — not planned
Reported on v2.1.141
Maintainer reply None cached
Activity 2 comments · opened May 14, 2026 · closed Jun 12, 2026

Summary

Claude Code extension v2.1.141 crashes the VS Code extension host with an unhandled Webview is disposed exception thrown from a setTimeout callback. The timer callback calls isVisible() on a webview that was disposed before the timer fired; no guard against the disposed state, so the assertion throws and brings down the entire extension host.

Environment

  • Claude Code extension: anthropic.claude-code-2.1.141-darwin-arm64
  • VS Code: 1.120.0
  • macOS: 26.3.1 (arm64)

Stack trace (from VS Code exthost.log)

2026-05-14 12:46:23.272 [info] ExtensionService#_doActivateExtension Anthropic.claude-code, startup: false, activationEvent: 'onWebviewPanel:claudeVSCodePanel'
...
2026-05-14 12:46:27.605 [error] Error: Webview is disposed
    at nN.assertNotDisposed (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:641:112549)
    at get visible (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:641:112155)
    at m8.isVisible (/Users/<user>/.vscode/extensions/anthropic.claude-code-2.1.141-darwin-arm64/extension.js:822:15363)
    at Timeout._onTimeout (/Users/<user>/.vscode/extensions/anthropic.claude-code-2.1.141-darwin-arm64/extension.js:814:1892)
    at listOnTimeout (node:internal/timers:585:17)
    at process.processTimers (node:internal/timers:521:7)
2026-05-14 12:46:28.010 [info] Extension host terminating: received terminate message from renderer
2026-05-14 12:46:28.024 [info] Extension host with pid 28081 exiting with code 0

Timing observation

The crash occurred ~4 seconds after the extension host activated (activation at 12:46:23.272, crash at 12:46:27.605). I suspect the offending timer was scheduled by a prior extension-host instance holding a reference to a webview that's now disposed, and the callback fires on the new session's first run.

Reproduction

Not reliably reproducible from a known sequence — happened twice in one day across reloads, both times within seconds of extension activation. Recent activity before the crash: closing/reopening the Claude panel and reloading the VS Code window during normal use.

Suggested fix

Guard the isVisible() call (and any other webview-touching call) inside the periodic timer callback with a disposed check, or cancel the timer in the webview's onDidDispose handler:

// extension.js around line 814 — current pattern
setInterval(() => {
  if (this.webview.isVisible) { /* ... */ }
}, ...)

// suggested
const t = setInterval(() => {
  if (this.disposed) return;
  try {
    if (this.webview.isVisible) { /* ... */ }
  } catch (_) { /* webview gone */ }
}, ...)
this.disposables.push({ dispose: () => clearInterval(t) });
// AND clear t in the webview's onDidDispose

Workaround until fixed

Avoid closing the Claude panel or switching workspaces during the first ~10 seconds after VS Code start.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗