I have VS Code 1.82, and when I try to open something that uses webviews, I sometimes get a notification with this error message:
Error loading webview: Error: Could not register service worker: InvalidStateError: Failed to register a ServiceWorker: The document is in an invalid state..
Places where I've observed this problem include things like the builtin media preview extension, which allows viewing image files, the adpyke.codesnap extension, the builtin Markdown Preview functionality, the Postman.postman-for-vscode extension, the rangav.vscode-thunder-client extension, using the builtin Simple Browser: Show command, the list goes on.
It also seems to be that startup times for VS Code are slower when this issue happens, and that if VS Code starts up with more normal startup times, the issue doesn't happen.
This is not the same issue as the one in Why am I getting an error when loading webviews in VS Code 1.56?. I am on VS Code 1.82 and not VS Code 1.56. I am not running VS Code with elevated privileges.
Why is this happening? How can I get things working again?
I've experienced this problem after I updated VSCode to 1.84.2 (Ubuntu 22.04, installed via snap) when I try to load a jupyter notebook.
As suggested by ChatGPT, I emptied the cache of VSCode by removing the contents of these folders ~/.config/Code/Cache, ~/.config/Code/CachedData and ~/.config/Code/GPUCache.
After a restart of VSCode, everything seems to work normally again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With