Error loading webview: Error: Could not register service workers: TypeError: Failed to register a ServiceWorker for scope - visual-studio-code

When I update my VSCode to v1.56.2 and open webview, I get these messages:
Error loading webview: Error: Could not register service workers:
TypeError: Failed to register a ServiceWorker for scope
('vscode-webview://867f875b-c5a3-4504-8de2-2e8614bdc0f8/') with script
('vscode-webview://867f875b-c5a3-4504-8de2-2e8614bdc0f8/service-worker.js?platform=electron&id=867f875b-c5a3-4504-8de2-2e8614bdc0f8&vscode-resource-origin=https%3A%2F%2F867f875b-c5a3-4504-8de2-2e8614bdc0f8.vscode-webview-test.com'):
ServiceWorker cannot be started.
How can I solve this issue?

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.

In Windows, you can simply fix this error by clearing the cache for VSCode. Please follow the steps below:
Close VSCode and also kill any background processes running in the task manager.
Go to the file explorer and to the path C:\Users\<user_name>\AppData\Roaming\Code and clear the contents of the folders Cache, CachedData, CachedExtensions, CachedExtensionVSIXs (if this folder exists) and Code Cache.
Open VSCode and you are good to go.

I encountered this issue and am not a Windows user, so this is my resolution:
I found that there was an instance of VS Code open that was erroneously not shown on my dock. I closed this instance and opened a new instance. The problem was gone.
I think the issue happened because I had a VS Code instance open, allowed a software update to run in the background, postponed the restart, opened a new and updated VS Code instance, and the old instance remained open causing conflicts.
OS: Ubuntu 20.04.2 LTS

#tritemio on GitHub has a great answer:
https://github.com/microsoft/vscode/issues/125993#issuecomment-912439561
in short, delete cache folder:
rm -rf ~/.config/Code/Cache

This is a known bug in VS Code 1.56. It happens for some Windows users when running VS Code as an administrator
As a workaround, you can try launching VS Code with the --no-sandbox command line flag:
$ code --no-sandbox

#tritemio, thanks for sharing.
This also seemed to solve my issues on Windows for "Extensions - Details View", "VS Code Release Notes View", "Gitlab integrated Interactive Rebase Editor", etc.
I followed your suggestion and deleted the following folders;
%appdata%\Code - Insiders\Cache
%appdata%\Code - Insiders\Code Cache

On *nix systems, first close VS Code app then run pgrep -f '/Applications/Visual Studio Code.app' | xargs kill to clean up vscode's processes. Reopen vscode and the issue will be gone.
If on macOS, you can run the above command verbatim. If you're not on macOS or installed vscode on a different location, you need to change the argument passed to pgrep. You can run ps auxww | command grep -i --color code to find the path of vscode's running processes.

Happened to me when started code in windows cmd. Closed vs code and opened it from my taskbar shortcut instead, and the error was gone

The simplest solution for this problem in any version of Linux is simply to close other instances of VS code and use only one instance of VS code.
OS: Linux 20.04.3 LTS

I've also encountered the same "Error loading web view" Error.
I've solved this issue by moving "vscode.app" into "Application folder" instead of "Download folder" on macOS.
I'll describe my "symptom" here.
OS: macOS 12.0.1
Installed 2 versions of vscode somehow, 1 under "Application folder", another under "download folder"
Run both vscode at the same time, the "download folder" version has no error display plugin pages, the "Application folder" version has the "Error loading webview" error
Checked and see 2 vscode instances running in the background
What I tried to solve this issue:
Tried to kill "download folder" instance, and the error remains for "application folder" instance
Moved "download folder" to "application folder" and both vscode works correctly on plugin page!
What I suspect on what the problem is?
Maybe these 2 vscode are sharing the same resource(could be some shared file), however they have different permissions since one is under application folder and another is under download folder.

This answer applies if using VSCode in GitHub Codespaces in Firefox or Brave browsers. I had to disable "Enhanced Tracking Protection" for the site, and that is all. To do so, click on the shield icon which is to the left of the displayed web address.

If anyone is using Brave, please turn off the brave shields as well.

For Mac/Apple computer Monteray version the following steps worked for me:
Delete VSCode from downloads folder.
Turn off VSCode
Open Activity Monitor and delete VSCode "Code" process.

Try closing all the process cmd+qof vscode and reopen vscode and everything should work well.

I have just restarted VS code and it worked for me. OS was Windows 10.

Related

Failed to connect to the remote extension host server (Error: Missing proxy instance MainThreadDebugService)

Hey stackoverflow community i have an issue with vscode connecting to wsl2 with the following error [picture bellow] message i already searched for hours and couldnt find a solution.
reinstalled both with a clean updated version without any success
Edit 1:Tried to unmount and remount folders also tried opening with high privilege's from cmd 'wsl code .' moreover i completely deleted wsl and vscode with all the extensions but still am getting the same error, i was able to reproduce more readable error, when opening a project it prompts with
unable to resolve resource vscode-re...://%ubuntu-22.04/file_path
Edit 2: opening WSL, 'New WSL window using distro' works fine but i cant open any directory, without it producing the error in Edit 1
I got the same issue. I use Windows and I open the folder in vscode in this way:
shift+right-click the folder -> open linux shell -> type in "code ."
when vscode opens, the error does not exist.
For me this was due to the secondary sidebar being visible.
After disabling it via View -> Appearance -> Secondary Side Bar, WSL2 starts up fine again.
I got the same.
If your project is on another drive mount it and
run vscode as administrator.
I had this issue and needed to run..
$ code
Updating VS Code Server to version 97dec172d3256f8ca4bfb2143f3f76b503ca0534
Removing previous installation...
Installing VS Code Server for x64 (97dec172d3256f8ca4bfb2143f3f76b503ca0534)
Downloading: 100%
Unpacking: 100%
Unpacked 2389 files and folders to /home/dmitri/.vscode-server/bin/97dec172d3256f8ca4bfb2143f3f76b503ca0534.
in WSL2 to update the WSL2 server. Then uninstalling and reinstalling the WSL extension from VSCode did the trick.
I am the same.
I also reinstalled VSCode and Docker, but nothing changed.
In the "Remote - Containers" tutorial, I was able to connect without any problems.
It doesn't work with my code.

VS Code Powershell "←]633;P;IsWindows=True"

I am working on a web application using Angular in Vs code.
I ran into some errors while I am fixing them in the process my vscode is bricked after a couple of minutes it return to its normal state but some weird beep sounds raised so i restarted my Laptop.
When I opened VS code again beep sound repeated and my powershell is showing some weird text
So, I thought the error this is due to some misconfigurations in my vscode and I uninstalled VScode ,deleted all related data
After installation the same weird text with beep sounds appeared again
The weird text
←]633;P;IsWindows=True
633;A633;P;Cwd=D:\user\website\quizPS D:\chiru\website\quiz> 633;B
←]633;C```
As #meganrogge said in https://github.com/microsoft/vscode/issues/160419 setting terminal.integrated.shellIntegration.enabled to false fixes this
I had in the settings Terminal > Integrated: Windows Enable Conpty (setting ID terminal.integrated.windowsEnableConpty) disabled. After re-enabling it again (which is the default) the problem went away for me.
Do you have scala sbt installed? it does not work well with ms power shell. On Windows it can be used via git bash for example. Go to your user vs code settings and adjust so following terminal integration will be active
"terminal.integrated.profiles.windows":{"Git Bash":{"path":"C:\\Program Files\\Git\\bin\\bash.exe"}, },
"terminal.integrated.defaultProfile.windows": "Git Bash",
the close your ms power shell tab in vs code terminal panel and add new bash one.
looks like there is a problem with powershell so i reinstalled my powershell it worked
I solved in this way:
Ctrl + Mayus + P
I faced the same issue. I uninstalled VS Code and installed again and the issue was resolved for me

VS Code's file changes watcher stopped working

I have vsc version 1.63.2. I'm getting the following notification:
"File changes watcher stopped unexpectedly. A reload of the window may enable the watcher again unless the workspace cannot be watched for file changes."
When I click the reload button, the issue is temporarily fixed and Source Control shows changes to my files. Git in CLI is working fine; git log --raw shows changes to my files correctly. I've tested brand new and old repositories and workspaces. The problem occurs in all of them. Any help troubleshooting this is greatly appreciated!
I just ran into this issue today and found my solution by viewing the "Window" logs using the "Developer: Open Log File..." command from the Command Palette.
In my case, the problem was that I had added a folder to my workspace that I had since deleted on the file system. The log in question looked something like:
... [error] [File Watcher (parcel)] Unexpected error: Invalid handle (EUNKNOWN) (path: \path\that\no\longer\exists)
... [error] [File Watcher (parcel)] restarting watcher after error: Invalid handle
Hopefully viewing this log helps you find out what's breaking in your specific case.
I also encountered this problem. I was using VSCode and opening a folder in it on WSL Ubuntu 20.04. The solution for me was to install the VS Code Remote - WSL extension.
I hope this will be useful for someone.
TLDR : on Windows 10, if you have Cygwin64 installed and you got a Git For Windows update, check Git for Windows path comes before Git from Cygwin path in environment variables.
Long version : Just got into the same error today. The Git Lens extension was not working anymore.
I'm on Win 10, so there is no way (at least I didn't find one) to increase the limit of watchers like on linux. My VS Code is v1.66.2, Git Lens extension is v12.0.6.
In my case, the logs said :
... [error] [File Watcher (parcel)] Unexpected error: Invalid handle (EUNKNOWN) (path: cygwin\g\path\that\exists)
Notice that ENOSPC !== EUNKNOWN
So I searched everywhere with little to no success, except here where Gordon Christopher Weeks's answer actually hinted me towards that logs.
Then I remembered several things :
I have a terminal installed that's called cygwin64 and that allows me to use some linux utilities otherwise not available on Win (like rsync);
two days ago, I authorized an update for Git for Windows (2.35.2);
when I installed cygwin, the tutorial I followed told me about following a certain sequence in the Windows path environment variable
So I checked the path variable, noticed the Git update deleted the initial path to git and put it in the last place. I only had to move it up, before the cygwin64 path to git.exe (a git utility is included with cygwin) and everything's back to normal.
Hope this helps and so you won't waste the time I did !
[Possible quick solution] First thing to check is to see if you are tracking a WSL folder in a Visual Studio Code Explorer workspace AND you switched VS Code back to windows (was in a WSL distro).
If so, then right-clicking on it and selecting "remove from workspace" will also remove it from the file change watcher.
Refresh the file change watcher (bell icon, lower right corner of window) to see if it cleans up the problem.
This was the issue I had with the system.

vs code not opening up in windows

whenever i try to open my vs code editor, nothing happens it doesn't launch and even there are no errors..!! And i am confused what's wrong here in my vs code. Please anyone help me fix it..!!
Below are the verbose command i typed in the terminal..
C:\Users\Avinash>code . --verbose
[main 2020-05-10T05:17:56.317Z] Error: UNKNOWN: unknown error, mkdir
[main 2020-05-10T05:17:56.318Z] Lifecycle#kill()
[main 2020-05-10T05:17:56.320Z] [File Watcher (node.js)] Error: UNKNOWN: unknown error, stat 'c:\Users\Avinash Maurya\AppData\Roaming\Code\User'
no need of Unistalling, just go to your vscode-setup and reinstall it. (by this procedure all of your's settings, files , extensions etc.. will be restored as it is.)
I also came across the same issue.
Uninstalling and Reinstalling it again worked out and all my extensions were there already(that was strange).
You may want to try "Run as Administrator".
try code --no-sandbox in kali linux
try this it worked for me!
got to the Microsoft store
install vs code form there
then an error massage will appear
now try to open your vs code and wait ...
You can try by searching vs code and if it opens you can right click it, create the shortcut and use it instead of the old shortcut. This worked for me so please try it.
Here is the best solution:
No need to uninstall or do anything.
I was also facing the same issue. Go to task manager. You'll see that visual studio code is running. Select it and press end task. Now you can open vscode normally. It's fixed!
Somehow I had two vs code installs on my computer (one user and one system) and they appeared to be conflicting. I uninstalled user and everything worked. I suggest uninstalling all versions and reinstalling using the system installer executable.
Just reinstall the vs code from previously downloaded setup, everything including extensions get restored. enjoy coding
I Have Got the Same Problem as you just open the folder where you have downloaded VS Code. Like in My case its in Drive C and open from icon in that folder.
you can fix this issue by selecting run this program as administrator under compatibility tab.
If you are on win10, kill all vscode processes, delete folder 'C:\Users\xxx\AppData\Roaming\Code', and launch vscode again.
if anyone is still wondering abt it, Microsoft ended support for Windows 7 in January, 2020 and no longer provides security updates. VS Code desktop versions starting with 1.71 (August 2022) will no longer run on Windows 7 and you will need to upgrade to a newer Windows version to use later versions of VS Code.
Thus, if you want to keep windows 7 version, you have to download an older version than 1.71 of VS Code , for example, 1.69 version (https://www.filepuma.com/download/visual_studio_code_64bit_1.69.1-32681/) and uncheck all the auto updates from the settings.
whenever you want to add any extension, you just have to choose the older version of it.
If you cannot open the vs code editor on windows 7, then you need to download the latest version 1.70.2 from July 2022, which is supported by windows 7. Here is a link as an example: https://update.code.visualstudio.com/1.70.2/win32-x64/stable

Receiving error message 'Extension host terminated unexpectedly.' in Visual Studio Code

I have been looking around and I haven't found any answers to my issue.
I keep getting this error "Extension host terminated unexpectedly." and I have tried removing all of my extensions, reinstalling the program, trying different versions of vscode including the insider versions.
The way I get this isssue isn't from trying to use the debugger or trying to use some sort of extension, as I said before I removed all of them and the error keeps on coming back, it's simply from opening the application. I'm not entirely sure how to continue? I have had to use another editor because the error just doesn't go away. I will just have to wait for another update of Visual Studio Code I assume? I've had the issue since tuesday this week, guessing since the latest update.
Above is the error message I get. It is closed by esc but reappears very shortly after, every time.
When I open developer tools, this is what I find in the console.
Running vscode from command prompt with Code.exe --disable-extensions doesn't help.
Visual Studio Code version: 1.16.1
I appreciate any help.
Linking my github issue on Microsoft/vscode as reference
I had the same error after updating vsc to v. 1.31.0.
Disabling Live Server Extension worked for me.
Here's the error i'm getting having the extension enabled.
I started getting this error when vscode automatically updated to March 2020 (version 1.44). I have tried various suggestions given in the forum and over the internet but none of them worked.
What worked for me: I downloaded January 2020 (version 1.42) build from https://code.visualstudio.com/updates/v1_42 and ran over the previous installation without uninstalling and surprisingly, the error disappeared and all extensions are loading and working properly.
I tried following things and non of them worked:
I disabled all the installed extension from GUI.
uninstalled all the extension and installed again.
removed the left-over extensions from Windows %USERPROFILE%.vscode\extensions.
tried launching from the command prompt with --disable-extensions option.
Linking my github issue on Microsoft/vscode as reference.
It ended up being one of the base extensions that runs on startup that was the root of the problem.
In my case the git in extensions folder was causing it.
"git.enabled": false was not doing the trick so I had to remove the git folder altogether for the error to disappear.
In my case, I used typescript-hero extension. Disabling this extension fixed my problem.
It's temporal fix but maybe will help somebody.
I disabled all the extensions with name Live for example Live Server, Live Share etc and restarted my vscode again and it worked for me.
For me this was happening due to HTML CSS Support extension. so i removed it and restarted vs code and voila! it worked!
I had to uninstall few extensions related to Java (debugger for java, Test runner for java, extension pack for java etc) to make the error go away.
Click on the developer tool option that popups and see if it has the extension which is causing this error.
I got same issue and it was because of Color Highlight Extension. I just uninstalled Color Highlight Extension and its working fine and NO ERROR.
Me too. My failure has no "Code":
Extension host terminated unexpectedly. Code: null Signal: SIGABRT
MessageService.ts
I recently ran into the same error message after accepting a permission to run a program on the extension livepreview. It corrupted all other extensions where it could not find the commands. I deleted all extension files and reinstalled the other extensions without a problem. I tried liveserver again but It never prompted me again for permissions and still, the error message keeps occurring. I'm assuming liveserver was trying to ask the computer permission to run a local server after which is still accepted but something else is interfering with the computer being able to translate from the program to actually building and accessing the local server.
In my case, the live server extension was causing this issue in 1.31.0v of VS Code. After uninstalling the extension it started working correctly.
In my case it was from the extension "Todo Tree". It was breaking on a particularly large file in my project (13.7mb), with the error saying the file was over the max-size for a node-buffer (used by the C regex matcher).
Resolved the issue by disabling the extension.
I also opened an issue for it here: https://github.com/Gruntfuggly/todo-tree/issues/135
I had same problem with following error in my VSCode console.
`1: node::DecodeWrite
2: node::InternalCallbackScope::Close
3: v8::internal::VirtualMemory::TakeControl
4: v8::internal::PerThreadAssertScope<4,1>::PerThreadAssertScope<4,1>
5: v8::internal::operator<<
6: v8::internal::operator<<
7: 00000073ECF04481`
I solved it by uninstalling Angular Console extension. Not sure if it was that particular extension or some other memory issue but problem went away as soon as I uninstalled that.
Remove all Extensions which are located in a per user extensions folder. Depending on your platform, the location is in the following folder:
Windows %USERPROFILE%\.vscode\extensions
macOS
~/.vscode/extensions
Linux ~/.vscode/extensions
Restart vscode and start installing extensions.
I am not sure why this caused , but the Antivirus was throwing popups that something like extensionprocess.js file was repaired.
Disabled the Antivirus and re-installed Vscode and it was back to normal.
Hope this helps.
Here is what helped me:
Ctrl+Shift+P --> type: "Disable"
and click Disable all installed extensions
(alternatively click Disable all installed extensions for this Workspace)
Then go to extensions panel on the left and re-enable slowly those that you really need.
See which extension (or their combination) triggers that error.
It will be highly appreciated which extenstion/combination you'll find guilty as there may be several of them, and different in time...
for me, it was code runner extension I just disabled it.