Error loading webview: Error: Could not register service worker: InvalidStateError: Failed to register a ServiceWorker: The document is in an invalid state..
The message
Error loading webview: Error: Could not register service worker: InvalidStateError: Failed to register a ServiceWorker: The document is in an invalid state..What it means
An extension's panel couldn't start, because the browser-side helper every webview needs failed to register. The bug comes from VS Code, which Cursor is built on, and nobody has pinned down the cause.
What to do
Quit every Cursor window and reopen it. If that doesn't clear it, quit again, delete the Service Worker folder in Cursor's user data folder, and start Cursor.
Cursor shows this as an error notification when you open an extension's panel (Cline, Jupyter, Git Graph and the Markdown preview have all been named) and the panel stays blank:
Error loading webview: Error: Could not register service worker: InvalidStateError: Failed to register a ServiceWorker: The document is in an invalid state..
The doubled full stop at the end is real. VS Code adds one after the browser's own message, which already ends in one.
Where the error comes from
A webview is the small embedded web page an extension uses to draw its own interface. Each one relies on a service worker (a background script the browser engine registers to serve the page's files). When that registration fails, the webview gives up and shows this notice.
None of this code is Cursor's. Cursor is built on VS Code, and both halves of the message live in VS Code's source: "Error loading webview: {0}" in webviewElement.ts and "Could not register service worker" in the webview's pre/index.html. The strings haven't changed between VS Code 1.105.1 and 1.137.0 in the releases we checked. Cursor 3.18.25 reports VS Code 1.128.0 as its base (About Cursor lists it as the VS Code Extension API version), and a Cursor user pasted the same code path from Cursor's console in March 2026.
Why nobody has fixed it
VS Code has been chasing this since June 2021 (more than five years as of September 2026). Issue #125993 is still open with 139 comments, and a GitHub search turns up 156 issues containing the phrase. A VS Code maintainer reproduced it in November 2021, and another said the webview host page shouldn't be navigated "while the service worker is loading". A regular contributor summed it up on a new report in August 2026: it "has occasionally been reported over many years without the root cause being traced. Restarting VS Code typically cures it."
A pull request in September 2026 tried to retry the registration automatically and reload the webview. It was closed without being merged. We'd expected the fix to be further along, given how long the issue has been open.
How to clear it in Cursor
- Quit Cursor completely, every window, and open it again. A Microsoft engineer on the Live Share team wrote in 2022 that when it happens "it is for all webviews" and they "have to close all instances" to get out of it. Reloading one window usually isn't enough (the stuck state seems to be shared by every open window).
- If it survives a restart, quit Cursor and delete the
Service Workerfolder in Cursor's user data folder. On a Mac that's~/Library/Application Support/Cursor/Service Worker. A VS Code maintainer suggested the same folder (plusCode Cache) back in 2021, and a user in the same thread reported it working in 2022. - Reinstalling the extension is what Cursor support suggested in 2024. The user who asked said it didn't help, which fits the VS Code thread: it's the editor's state that's stuck.
One maintainer's repro was quitting and then relaunching very quickly, so after quitting we'd give Cursor a few seconds before opening it again.
A related problem with two windows
In June 2026 an extension developer reported webviews staying blank in a second Cursor window until the first was closed, with console lines about an "unexpected service worker controller". Cursor staff thought the same panel in two windows "may resolve to the same vscode-webview:// origin and the same service worker scope" and took it to investigate. If your panels only break when two windows are open, that's probably the one you're hitting.
Other lines the same feature prints
Match yours against these if the one at the top of the page is not quite it. They come from the same code and mean related things.
Error loading webview: Error: Could not register service worker: InvalidStateError: Failed to register a ServiceWorker: The document is in an invalid state…