[BUG] VSCode Extension fails to load with ServiceWorker error when ~/.claude/projects folder doesn't exist
Open 💬 2 comments Opened Jan 13, 2026 by NiceBlueSky8
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
The Claude Code VSCode extension fails to load with a ServiceWorker registration error. The webview remains blank and displays the error:
Error loading webview: Error: Could not register service worker: InvalidStateError: Failed to register a ServiceWorker: The document is in an invalid state..
<img width="717" height="123" alt="Image" src="https://github.com/user-attachments/assets/1d2f3802-917e-4441-8b25-225b3e8e144c" />
After debugging, I found two issues:
- Missing
projectsfolder: The extension tries toscandiron~/.claude/projects/which doesn't exist. The folder was never created during installation.
- Corrupted Service Worker cache: The
%APPDATA%\Code\Service Workerfolder contained corrupted cache data.
Workaround:
- Create the missing folder:
mkdir "$env:USERPROFILE\.claude\projects" - Close VSCode, delete
%APPDATA%\Code\Service Worker, restart VSCode
What Should Happen?
The extension should:
1. Automatically create `~/.claude/projects` folder if it doesn't exist during initialization
2. Handle missing project subdirectories gracefully without crashing
3. Not leave the webview in an unrecoverable ServiceWorker error state
Error Messages/Logs
[Extension Host] rejected promise not handled within 1 second: Error: ENOENT: no such file or directory, scandir 'C:\Users\sample_user\.claude\projects\c--Users-sample_user-dev-sample-project'
[Extension Host] stack trace: Error: ENOENT: no such file or directory, scandir 'C:\Users\sample_user\.claude\projects\c--Users-sample_user-dev-sample-project'
at async readdir (node:internal/fs/promises:958:18)
at async t.performRefresh (c:\Users\sample_user\.vscode\extensions\anthropic.claude-code-2.1.5-win32-x64\extension.js:17:7322)
at async t.load (c:\Users\sample_user\.vscode\extensions\anthropic.claude-code-2.1.5-win32-x64\extension.js:17:7148)
[Anthropic.claude-code] ENOENT: no such file or directory, scandir 'C:\Users\sample_user\.claude\projects\c--Users-sample_user-dev-sample-project'
Webview fatal error: Error: Could not register service worker: InvalidStateError: Failed to register a ServiceWorker: The document is in an invalid state..
Error loading webview: Error: Could not register service worker: InvalidStateError: Failed to register a ServiceWorker: The document is in an invalid state..
Steps to Reproduce
- Fresh install (or reinstall) Claude Code VSCode extension v2.1.5
- Ensure
~/.claude/projectsfolder does NOT exist (only~/.claude/ideexists) - Open any project in VSCode
- Click the Claude Code icon to open the panel
- Extension fails to load with ServiceWorker error and blank webview
Environment:
- Windows 11
- VSCode (latest stable)
- Claude Code Extension v2.1.5
Claude Model
None
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.5
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
PowerShell
Additional Information
Suggested Fix:
Add defensive initialization code in the extension:
const projectsDir = path.join(os.homedir(), '.claude', 'projects');
if (!fs.existsSync(projectsDir)) {
fs.mkdirSync(projectsDir, { recursive: true });
}
Notes:
- The
~/.claude/idefolder was correctly created by the extension - Only the
projectsfolder was missing - This appears to be a missing initialization step during extension setup
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗