vscode: Unable to run sandboxed process when run as elevated under applocker

  • VS Code Version: 1.56.0-insider (user setup)
  • OS Version: Windows_NT x64 10.0.19042
  • Electron: 12.0.4
  • Chrome: 89.0.4389.114
  • Node.js: 14.16.0
  • V8: 8.9.255.24-electron.0

Steps to Reproduce:

  1. Open a markdown file, and click the “Open preview to the side” button
  2. The preview window is blank, and an error notification pops up in the bottom right:

Error loading webview: Error: Could not register service workers: TypeError: Failed to register a ServiceWorker for scope (‘vscode-webview://36f8a74c-37c6-4d60-9d4c-87414f69ebcc/’) with script (‘vscode-webview://36f8a74c-37c6-4d60-9d4c-87414f69ebcc/service-worker.js?platform=electron&id=36f8a74c-37c6-4d60-9d4c-87414f69ebcc&vscode-resource-origin=https%3A%2F%2F36f8a74c-37c6-4d60-9d4c-87414f69ebcc.vscode-webview-test.com’): ServiceWorker cannot be started.

The same thing happens for other WebViews, like opening an extension from the Extensions sidebar, or using the “Issue Reporter”.

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

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 92
  • Comments: 121 (31 by maintainers)

Most upvoted comments

I killed existing related processes, this works again for me.

ps aux | grep -i vscode | less
pkill -f vscode

@eduncan911 and others who are facing the issue on linux, please open a separate issue as the root cause is unrelated. This issue only tracks the problem on windows due to chromium sandbox disallowing to start the service worker process when run as elevated.

I killed existing related processes, this works again for me.

ps aux | grep -i vscode | less
pkill -f vscode

I encountered this problem after upgrading vscode server and solved it by killing all existing vscode-server processes and restarting vscode all over.

In my case, this seems to be related to some conflicts between the upgrade operation and the previous processes.

I know this is probably expected but just wanted to add that this is still broken in 1.57.0

Since 1.66 as non-admin nothing works anymore. “no-sandbox” param works as a workaround, but sounds not like the right way doing it. Can you fix this serious bug, please?

Actually, 1.59 on windows, still can’t open the any web view extension, even no error popup, any solutions or fix plan?

image

Don’t know if it is the same issue, no WebView opens in either of my windows, local/remote

Version: 1.58.0
Commit: 2d23c42a936db1c7b3b06f918cde29561cc47cd6
Date: 2021-07-08T06:53:55.113Z
Electron: 12.0.13
Chrome: 89.0.4389.128
Node.js: 14.16.0
V8: 8.9.255.25-electron.0
OS: Linux x64 5.4.0-74-generic snap

Just had this issue. I closed two code windows, then quickly opened up another one that had a markdown preview already open and was unable to load the preview exactly like issue 128649. I closed the preview, opened a new one, same issue. Restarted code a few times, same error.

Finally I closed Code, ran ps -ef | grep -i code did not return any running instances. I let it sit for about 20 seconds, launched Code again, and was able to load the preview.

I’m on Ubuntu 22.04, installing from the apt repo, not using a Snap. Non-insiders.

Version: 1.73.0
Commit: 8fa188b2b301d36553cbc9ce1b0a146ccb93351f
Date: 2022-11-01T15:44:09.336Z
Electron: 19.0.17
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Linux x64 5.15.0-52-generic
Sandboxed: No

The --no-sandbox parameter fixed it for me (running as admin).

I had similar issue on Ubuntu, For me upgrading VScode to 1.59 and google chrome to 92 fixed the issue.

@deepak1556 all other Linux issues related to this were closed as Duplicates, and pointed to this long thread. That means people need to retrospectively find and re-open those other issues.

Also, doesn’t this ticket have the Linux label ? ¯\_(ツ)_/¯

Hello All, I’m in the Azure Edge Robotics team, maintaining the VSCode extension for ROS. We are hitting this issue as well for our Robot Visualizer. It seems to be related to a move from vscode-resource to https?

For example, we have a workspace rooted at c:\ws\tb, which has sources including stl files. We convert this to a file URI, then to a webview URI. Before the update, it would look something like: vscode-resource://c%3A/ws/tb/src/turtlebot3/turtlebot3_description/meshes/wheels/right_tire.stl

but now looks like this:

https://47c83f32-da7e-4be3-9b90-42735e27223e.vscode-webview-test.com/vscode-resource/file///c%3A/ws/tb/src/turtlebot3/turtlebot3_description/meshes/wheels/right_tire.stl 

The file/// does not look right to me.

For me using code --no-sandbox solved the problem and I can see the Markdown Preview on one of my machines (running on VM). On other machines - it doesn’t help at all.

I have noticed this issue on the stable build of 1.56.0 that was just released. I have found it only happens if I run vscode as administrator. I noticed because I couldn’t read the release notes 😂

Error loading webview: Error: Could not register service workers: TypeError: Failed to register a ServiceWorker for scope (‘vscode-webview://vs_code_release_notes/’) with script (‘vscode-webview://vs_code_release_notes/service-worker.js?platform=electron&id=vs_code_release_notes&vscode-resource-origin=https%3A%2F%2Fvs_code_release_notes.vscode-webview-test.com’): ServiceWorker cannot be started.

On Windows 11 (v1.82.2) with standard install, there is a workaround:

  1. Pin vscode to the taskbar.
  2. Right click the icon there -> New Window.
  3. For that session the WebViews load fine, I didn’t see any warnings/errors.

@deepak1556 could you provide a link to the Linux issue you reportedly re-opened?

Like many others, I searched through 10s of auto-closed issues and chains of auto-generated “look at this issue” before coming across this issue. While I acknowledge that probably saves you a lot of time, it is an objectively horrible experience for users faced with genuine bugs.

Thanks!

Any updates on issue solution? running VSCode as admin and unable to view extension webview in app. --no-sandbox workaround does not really help

I get this issue when trying to open Git History (https://marketplace.visualstudio.com/items?itemName=donjayamanne.githistory). This used to work a few days ago, but now the window is blank with the error message: Screenshot from 2021-07-08 10-24-39

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

Just a note to say --no-sandbox is no longer available in the newest version and this webview error still persists (particularly in Latex-workshop

$ code --help
Visual Studio Code 1.57.1

Usage: code [options][paths...]

To read from stdin, append '-' (e.g. 'ps aux | grep code | code -')

Options
  -d --diff <file> <file>           Compare two files with each other.
  -a --add <folder>                 Add folder(s) to the last active window.
  -g --goto <file:line[:character]> Open a file at the path on the specified line and character position.
  -n --new-window                   Force to open a new window.
  -r --reuse-window                 Force to open a file or folder in an already opened window.
  -w --wait                         Wait for the files to be closed before returning.
  --locale <locale>                 The locale to use (e.g. en-US or zh-TW).
  --user-data-dir <dir>             Specifies the directory that user data is kept in. Can be used to open multiple distinct instances of Code.
  -h --help                         Print usage.

Extensions Management
  --extensions-dir <dir>                                      Set the root path for extensions.
  --list-extensions                                           List the installed extensions.
  --show-versions                                             Show versions of installed extensions, when using --list-extensions.
  --category <category>                                       Filters installed extensions by provided category, when using --list-extensions.
  --install-extension <extension-id[@version] | path-to-vsix> Installs or updates the extension. The identifier of an extension is always `${publisher}.${name}`. Use `--force` argument to update to latest
                                                              version. To install a specific version provide `@${version}`. For example: 'vscode.csharp@1.2.3'.
  --uninstall-extension <extension-id>                        Uninstalls an extension.
  --enable-proposed-api <extension-id>                        Enables proposed API features for extensions. Can receive one or more extension IDs to enable individually.

Troubleshooting
  -v --version                       Print version.
  --verbose                          Print verbose output (implies --wait).
  --log <level>                      Log level to use. Default is 'info'. Allowed values are 'critical', 'error', 'warn', 'info', 'debug', 'trace', 'off'.
  -s --status                        Print process usage and diagnostics information.
  --prof-startup                     Run CPU profiler during startup.
  --disable-extensions               Disable all installed extensions.
  --disable-extension <extension-id> Disable an extension.
  --sync <on> <off>                  Turn sync on or off.
  --inspect-extensions <port>        Allow debugging and profiling of extensions. Check the developer tools for the connection URI.
  --inspect-brk-extensions <port>    Allow debugging and profiling of extensions with the extension host being paused after start. Check the developer tools for the connection URI.
  --disable-gpu                      Disable GPU hardware acceleration.
  --max-memory <memory>              Max memory size for a window (in Mbytes).
  --telemetry                        Shows all telemetry events which VS code collects.

I am having the same issue as described in #128649 on OS-X in Version 1.82.2

@elvinagam - did you try closing all vscode instances as noted here? For me, killall code - restart, and it started working again.

I use vscode to develop and debug PowerShell scripts. And because of AppLocker, PowerShell is run in Constrained Language Mode, disabling a lot of needed features. https://devblogs.microsoft.com/powershell/powershell-constrained-language-mode/

Also still seeing this in 1.67.1 while not running as Administrator. As people have mentioned, closing all instances of VSCode and restarting generally fixes the issue.

Can we make a  --no-sandbox a config setting?

  • My company forces VSCode to run as admin
  • Opening a file from Explorer ignores the command line parameters on shortcuts
  • Thus I can’t use VSCode to open files directly. I have to start VSCode first, then open files from inside it

Still getting a blank screen with any preview or report issue. No longer getting a webview error.

Version: 1.63.2 (system setup) Commit: 899d46d82c4c95423fb7e10e68eba52050e30ba3 Date: 2021-12-15T09:40:02.816Z Electron: 13.5.2 Chromium: 91.0.4472.164 Node.js: 14.16.0 V8: 9.1.269.39-electron.0 OS: Windows_NT x64 10.0.19042

@joshxyzhimself restarting VSCode is not always the same as restarting all of its background processes. Please check my Aug 29 comment or restart your system to be sure.

Fixed with restart of Ubuntu at v1.61.2

I noticed a left out process tree after closing my VSCode and search for “code” on my system monitor. When I terminated it and reopen VSCode, the problem was resolved.

OS: “Ubuntu 20.04.3 LTS (Focal Fossa)” VSCode version: 1.59.1 Commit: 3866c3553be8b268c8a7f8c0482c0c0177aa8bfa Date: 2021-08-19T11:54:37.513Z Electron: 13.1.7 Chrome: 91.0.4472.124 Node.js: 14.16.0 V8: 9.1.269.36-electron.0 OS: Linux x64 5.11.0-27-generic snap

Happy to report symptoms have disappeared on Linux-based platforms on upgrade to VS Code 1.57.0, but still present on Windows 10.

The webview problem was manifesting for me with:

  • built-in Markdown preview
  • PDF rendering (plugin: vscode-pdf by tomoki1207)

Here are the application stacks for my installations:

Ubuntu 20.04.2 LTS (Focal Fossa) working

Version: 1.57.0
Commit: b4c1bd0a9b03c749ea011b06c6d2676c8091a70c
Date: 2021-06-09T17:18:42.895Z
Electron: 12.0.9
Chrome: 89.0.4389.128
Node.js: 14.16.0
V8: 8.9.255.25-electron.0
OS: Linux x64 5.4.0-74-generic

Chrome OS 91.0.4472.81 (Official Build) (64-bit) working

Version: 1.57.0
Commit: b4c1bd0a9b03c749ea011b06c6d2676c8091a70c
Date: 2021-06-09T17:18:42.895Z
Electron: 12.0.9
Chrome: 89.0.4389.128
Node.js: 14.16.0
V8: 8.9.255.25-electron.0
OS: Linux x64 5.4.109-26077-g12746d86825a

Windows 10 Professional broken

Version: 1.57.0 (system setup)
Commit: b4c1bd0a9b03c749ea011b06c6d2676c8091a70c
Date: 2021-06-09T17:18:42.354Z
Electron: 12.0.9
Chrome: 89.0.4389.128
Node.js: 14.16.0
V8: 8.9.255.25-electron.0
OS: Windows_NT x64 10.0.19041

Also seems to be happening to a few Linux users, see #125993

On other machines - it doesn’t help at all.

@StanKirilov Can you run with code --no-sandbox --user-data-dir <specify-some-absolute-directory-path-here>

@haugerbr can you launch with code.cmd --no-sandbox and check if it helps. If not, can you attach the output of code.cmd --verbose