microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.36k stars 28.6k forks source link

Webview Service Worker Error in registration due to invalid document state #125993

Open tritemio opened 3 years ago

tritemio commented 3 years ago

Does this issue occur when all extensions are disabled?: No

Steps to Reproduce:

  1. Update to 1.57
  2. GitGraph extension stops working

The gitgraph extension shows this error:

Error loading webview: Error: Could not register service workers: InvalidStateError: Failed to register a ServiceWorker: The document is in an invalid state..
hgehlhausen commented 1 year ago

I have a known solution on Ubuntu 22.04

I deleted my "~/.config/Code" folder and was able to restore functionality. Its going to be a pain installing all my extensions again, but I've narrowed down the error ( at least in my system )

You can probably fix the issue by clearing the Code folder, or by clearing your "settings". What I suspect is that VS code has some older config-settings which break when updating the version, or become corrupted by some other process.

Note: I did try using the --no-sandbox option with no effect, and had some effect with --user-data-dir ~/fakeFolder, pointing me to the ~/.config/Code deletion solution.

Leigh-M commented 1 year ago

I am seeing this when trying to view the latest Release Notes:

Error loading webview: Error: Could not register service workers: InvalidStateError: Failed to register a ServiceWorker: The document is in an invalid state..

mrliptontea commented 1 year ago

I just hit this issue with the latest release trying to display the Release Notes. I deleted ~/.config/Code/Service Worker (+ all directories with Cache in the name) and now it's working again.

Leigh-M commented 1 year ago

Restarting my machine worked as well.. the old faithful turn it off an on again..! ;-)

mavinii commented 1 year ago

I am using Fedora and I had the same problem, and believe or not, the problem was because of Brave, do not ask me why. I tried get copilot working and I got this error.

What I did was that:

Done. VSCode working again as well as copilot.

UlisseMini commented 1 year ago

rm -rf .config/Code/Service\ Worker/{CacheStorage,ScriptCache} followed by pkill code worked for me without restarting my whole machine.

fbarikzehi commented 1 year ago

I found that the problem ca be fixed without rebooting by removing all the cache folders used by vscode:

* close vscode (make sure no process is running)

* `rm -rf ~/.config/Code/*Cache*`

* open vs code

Worked for me.Thanks

chris-aeviator commented 1 year ago

I'm affected by this on linux, not even the markdown preview works. I have a lot of [code] <defunct> entries in my ps -ef list. killall code won't remove them (same with pkill). Restarting your computer to fix your code editor is such a microsofty thing and should never be asked from linux users :smiley:

Edit: after waiting a bit (multiple minutes) the zombie processes have been cleaned up and I can use webviews again without a restart. I also deleted the Cache files, but it did not have any immediate effect.

qadram commented 1 year ago

I'm not sure why #178834 was closed, because this issue is happening when updating to 1.77, and 1.76.2 worked perfectly. I have been checking and this change should have caused the issue:

https://github.com/microsoft/vscode/pull/177716/commits/f71995e0b16ec2429cbbd221714984197ff5259d#diff-2f29d5590142a69ba7b8500a64b19f6bffb00b3b6bace7329976f6e5fea88649

My extension is totally broken because the webview cannot show my web app and it's kind of difficult to send you a reproducible test case.

arashilmg commented 1 year ago

/label important

starball5 commented 1 year ago

Possibly related on Stack Overflow: Error loading webview: Error: Could not register service workers: TypeError: Failed to register a ServiceWorker for scope

Sberm commented 1 year ago

On windows that's %AppData%\Code\Cache

rdking commented 1 year ago

Also happens in 1.80.0 and 1.80.1 with "Hex Editor" installed and trying to open a binary file.

DiguyaDeveloper commented 1 year ago

rm -rf .config/Code/Service\ Worker/{CacheStorage,ScriptCache}

pkill code rm -rf .config/Code/Service\ Worker/{CacheStorage,ScriptCache}

Obrigado, essa solução funcionou para mim, estou usando a versão 23.x do ubuntu

bryanmramsamy commented 11 months ago

I still have the issue and rebooting or restarting VS Code over and over again works, but is extremely time-consuming and therefore not a viable option.

BadLice commented 11 months ago

I'm still having this issue running GitLens commands. I'm on Ubuntu. This error occured after updating to version 1.82

ssibrahimpur commented 11 months ago

Issue still persist on latest version

image

jkoubs commented 11 months ago

The issue appeared to me when trying updating a new vscode version. Solution: Reboot pc, thanks @tritemio

enkeyz commented 11 months ago

For me it occurs anytime I install an extension, which opens up their setting page right after. Restarting vscode fixes the issue for some time.

tp1050 commented 11 months ago

rm -rf .config/Code/Service\ Worker/{CacheStorage,ScriptCache} followed by pkill code worked for me without restarting my whole machine.

worked like a charm.

wafflemakr commented 10 months ago

I just hit this issue with the latest release trying to display the Release Notes. I deleted ~/.config/Code/Service Worker (+ all directories with Cache in the name) and now it's working again.

This worked like a charm for me in Ubuntu, remember to refresh VSCode! thanks a lot!

Tyriar commented 7 months ago

This isn't a linux/snap issue, I've seen it plenty of times on Windows.

QuentinSc commented 6 months ago

Get it on windows, on a fresh install

saadazghour commented 6 months ago

If you are using Ubuntu, there is probably another (maybe hidden) vscode process, which is causing the problem.

Close the vs code first and in terminal try: killall code

mminot-yseop commented 6 months ago

Got that all of a sudden on 1.87.0. OK after reboot but I hope it won’t come back too often. 😆 (Xubuntu 20, .deb package install)

fabriceleal commented 5 months ago

This could be a blink bug, maybe resulting from some sort of race condition ... the error is triggered here https://github.com/chromium/chromium/blob/main/third_party/blink/renderer/modules/service_worker/service_worker_container.cc#L427-L430

The provider_ might not be set at creation https://github.com/chromium/chromium/blob/main/third_party/blink/renderer/modules/service_worker/service_worker_container.cc#L176-L181

juanma-avio commented 4 months ago

Easy workaround on Linux:

  1. exit vs code
  2. in the console write: "killall code"
  3. start vs code again
caiqichang commented 4 months ago

i got this problem when i open second vscode windows. only first vscode window can work well, webview in the other windows broken down.

vscode version: 1.89.0 pc: windows 11

yan-pi commented 3 months ago

Same issue Here!!

Does this issue occur when all extensions are disabled?: No, sice i need to install the markdown extension to occur

VS Code Version: 1.89.1 https://github.com/microsoft/vscode/commit/dc96b837cf6bb4af9cd736aa3af08cf8279f7685 x64 OS Version: linux fedora 40 linux kernel 6.8.9-300.fc40.x86_64 Steps to Reproduce:

Install markdown preview or other Rxtension that uses webview Run the command to show webview

BMourguesFieldbox commented 3 months ago

rm -rf .config/Code/Service\ Worker/{CacheStorage,ScriptCache} followed by pkill code worked for me without restarting my whole machine.

worked like a charm.

Same, worked perfectly, quote replying for future readers

Doc-Tiebeau commented 1 month ago

rm -rf .config/Code/Service\ Worker/{CacheStorage,ScriptCache} followed by pkill code worked for me without restarting my whole machine.

worked like a charm.

Works for same issue when displaying markdown and png files.

OS: Debian Bookworm 12.6 VScodium : 1.91.1 Release : 24193 Context : ~/.config/VSCodium synchronized using rsync from previous machine (Ubuntu + Snap)