vscode: Error received from starting extension host when `BackgroundShortcutRunner` is in `$TMPDIR`

Issue Type: Bug

Overview

Upon opening of subsequent windows, VSCode fails to load/start the extension host.

Expected vs Actual

Expected: Open VSCode Open subsequent VSCode windows VSCode runs

Actual: Open VSCode Open subsequent VSCode windows VSCode runs, but without any extensions - thus, it is unusable

Reproduction Steps

For reproduction, it most reliably happens in this order:

  1. Restart machine
  2. Open a project in vscode a. At this point it’s worth noting that generally there are no problems at this point. But it has happened where even the first window exhibits the problem.
  3. Open another project in vscode
  4. At this point - generally - vscode is unusable as the extension host failed to start.

All subsequent windows fail to function, but the original window can still function as normal.

Up to now, the only way I have seen to resolve this issue is to restart my machine. And the other aspect is that it doesn’t always happen with the reproduction steps. Sometimes it will run as normal. But it does seem to have started happening in the past month or so - sorry but I don’t know what release it started after.

Stack Trace

With a clean slate, this was the output when running Restart Extension Host:

[2021-12-21 10:37:52.334] [renderer1] [error] Error received from starting extension host (kind: LocalProcess)
[2021-12-21 10:37:52.335] [renderer1] [error] Error: listen EADDRINUSE: address already in use /var/folders/hl/0bhmctbx6_qdyg701bqz4wfh0000gn/T/com.apple.WorkflowKit.BackgroundShortcutRunner/vscode-ipc-5ab648a9-d244-4c6d-9a80-7f2accc14d8d.sock
    at Server.setupListenHandle [as _listen2] (net.js:1301:21)
    at listenInCluster (net.js:1366:12)
    at Server.listen (net.js:1463:5)
    at vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:2984:27713
    at new Promise (<anonymous>)
    at q._tryListenOnPipe (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:2984:27554)
    at q.start (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:2984:23414)
    at new es (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:1557:5175)
    at y._createInstance (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:574:1354)
    at y.createInstance (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:574:773)
    at d (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:1557:4437)
    at vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:2982:31830
    at Array.forEach (<anonymous>)
    at jl._startExtensionHosts (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:2982:31778)
    at jl.startExtensionHosts (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:2982:32726)
    at async jl.restartExtensionHost (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:2982:32939)

VS Code version: Code 1.63.2 (899d46d82c4c95423fb7e10e68eba52050e30ba3, 2021-12-15T09:37:28.172Z) OS version: Darwin x64 21.2.0 Restricted Mode: No

System Info
Item Value
CPUs Intel® Core™ i5-1038NG7 CPU @ 2.00GHz (8 x 2000)
GPU Status 2d_canvas: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled
Load (avg) 2, 2, 2
Memory (System) 16.00GB (1.02GB free)
Process Argv . --crash-reporter-id 3bd0b795-da19-4cd2-95f1-3fc581bf676d
Screen Reader no
VM 0%
Extensions (27)
Extension Author (truncated) Version
alpine-js-intellisense adr 1.2.0
language-antlers ahd 0.1.0
laravel-extra-intellisense ami 0.6.1
laravel-blade-spacer aus 2.1.3
vscode-intelephense-client bme 1.8.0
vscode-tailwindcss bra 0.7.4
path-intellisense chr 2.6.0
livewire-vscode cie 0.2.8
xml Dot 2.5.1
vscode-great-icons emm 2.1.79
json-tools eri 1.0.2
php-debug fel 1.22.0
php-pack fel 1.0.2
beautify Hoo 1.5.0
better-pest m1g 0.1.0
php-namespace-resolver Meh 1.1.8
dotenv mik 1.0.1
python ms- 2021.12.1559732655
vscode-pylance ms- 2021.12.2
jupyter ms- 2021.11.1001550889
jupyter-keymap ms- 1.0.0
jupyter-renderers ms- 1.0.4
test-adapter-converter ms- 0.1.5
laravel-blade one 1.28.0
markdown-preview-enhanced shd 0.6.1
swdc-vscode sof 2.6.19
vscodeintellicode Vis 1.2.15
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492:30256859
vstes627:30244334
pythontb:30283811
pythonvspyt551cf:30345471
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscorecescf:30384386
pythondataviewer:30285071
vscod805:30301674
pythonvspyt200:30340761
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
pythonvs932:30410667
vscop804:30404766
vs360cf:30404996
vsrem710cf:30416617
vscexrecpromp3c:30407761

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 3
  • Comments: 35 (9 by maintainers)

Most upvoted comments

Man alive, I’m very pleased to find this thread finally. This error is also affecting me, and has been for quite sometime, and I (like @nedwors mentioned) have only been able to get around it by restarting my mac.

After reviewing everything said here, and testing some things out here, this is what I’ve found. First, though, here is my relevant setup / routine.

My Setup / Routine

  • macOS 12.0.1 (Monterrey)
  • I almost exclusively use code . to open VS Code
  • I don’t use Shortcuts to open VS Code, but I DO use a shortcut to bootstrap my machine every morning, as I shut it off entirely every night
  • I’m a consultant and work in several different client codebases throughout the day, and have to open different VS Code workspaces throughout any given workday.

$TMPDIR Results

When I echo $TMPDIR from my standard terminal (not in VS Code), I get the following:

/var/folders/q9/2mn18mnj2d13tq1n2mxm81cm0000gn/T/

However, when I run that from within the embedded VS Code terminal (regardless of the method for launching VS Code), this is what I get:

/var/folders/q9/2mn18mnj2d13tq1n2mxm81cm0000gn/T/com.apple.WorkflowKit.BackgroundShortcutRunner/

Observations

So, after doing some testing, much more focused thanks to this thread, I found the following interesting observations:

  • If I launch VS Code via code . fresh after restarting my mac, the extension host works just fine
    • If I launch another workspace via code ., or even if I just reload the window of the same workspace, even after fully quitting VS Code, I get the error mentioned by OP
  • If I launch VS Code via opening the application directly, regardless of whether or not I launched VS Code before, the extension host works just fine.
    • Interestingly enough, launching from the application itself seems to “reset” the code . problem. Take the following example that I tested:
  1. Launch with code . --> Extension host works
  2. Reload window (or launch different workspace) --> Extension host fails with error
  3. Quit VS Code and relaunch with code . --> Extension host fails with error
  4. Quit VS Code and launch from the application icon --> Extension host works
  5. Launch different directory (or same one after quitting) via code . --> Extension host works
  6. Reload window (or launch different workspace) --> Extension host fails with error

Final Thoughts

I don’t know if this is actually a bug with VS Code or Monterrey or both. However, it appears that (at least for the time being) the only way I can get around this is to launch directly from VS Code itself, rather than from code .. If anyone else happens to know of a way to fix this, or if I need to update something, please let me know, as I’d much rather launch from the command line.

I also use Shortcuts to launch a number of apps when I boot up my machine. Visual Studio Code is not one of them, but I experience the same sort of issues that are described in this thread.

It looks like the issue is caused by one of your installed extensions. All extensions execute together on a single nodejs process, so in order to narrow down the possible problematic extension, please try the following:

  • run F1 > Help: Start Extension Bisect
  • (this will restart VS Code with half of your extensions disabled)
  • try to do the steps which reproduce the problem
  • if the problem reproduces, click “This is bad” (this narrows down the problematic extension to the half which was enabled)
  • if the problem does not reproduce, click “Good now” (this narrows down the problematic extension to the half which was disabled)
  • these steps will repeat until the problematic extension is found
initial step final
image image image

After going through this thread I ran some tests and was able to make the issue go away on a new instance without restarting my mac.

My first instance of vs code is opened via shortcuts like a lot of people mentioned and the extension host works fine. These shortcuts also open my terminal. Echoing $TMPDIR on the first instance gives me this:

/var/folders/q3/7k44dy2j0mg2mbg1n68z697c0000gn/T/com.apple.shortcuts.mac-helper/

After that, if I open any other new instance from the terminal via code . and echo $TMPDIR again, I get:

/var/folders/q3/7k44dy2j0mg2mbg1n68z697c0000gn/T/com.apple.WorkflowKit.BackgroundShortcutRunner/

The first instance with the BackgroundShortcutRunner works fine. After that, any new instances will echo the same result and the extension host will stop working. I thought it had to do with the terminal being open initially from the shortcuts application, so I quitted the terminal, reopened it manually and then I was able to open a new vs code instance via code . where everything worked just fine. Also, on this new instance after reopening the terminal, the result of echoing $TMPDIR is:

/var/folders/q3/7k44dy2j0mg2mbg1n68z697c0000gn/T/