vscode: Extension host terminated unexpectedly after 1.26.0 update

Issue Type: Bug

When I open VS Code I get a toast that says “Extension host terminated unexpectedly.”

Usually this happens on startup, but occasionally extensions remain functional until I open, close, switch, or save a tab.

This never occurred before I updated to v.1.26.0 this morning. I saw a few similar issues, but they seem to end up being related to extensions I don’t use such as ruby or go.

Dev tools output

 INFO no standard startup: not a new window
console.ts:136 [Extension Host]% {0: "extensions/defaults.json", 1: "{↵  "accents": {↵    "Acid Lime": "#C6FF00",↵    "…",↵    "Palenight High Contrast": "vs-dark"↵  }↵}"}
extensionService.ts:374 Extension host terminated unexpectedly. Code:  null  Signal:  SIGPIPE
w._onExtensionHostCrashed @ extensionService.ts:374
(anonymous) @ extensionService.ts:369
e.fire @ event.ts:140
t._onExtHostProcessExit @ extensionHost.ts:430
(anonymous) @ extensionHost.ts:215
emitTwo @ events.js:126
emit @ events.js:214
__dirname.ChildProcess._handle.onexit @ internal/child_process.js:198
notificationsAlerts.ts:41 Extension host terminated unexpectedly.
t.onDidNotificationChange @ notificationsAlerts.ts:41
(anonymous) @ notificationsAlerts.ts:27
e.fire @ event.ts:140
t.notify @ notifications.ts:113
t.notify @ notificationService.ts:56
t.prompt @ notificationService.ts:88
w._onExtensionHostCrashed @ extensionService.ts:382
(anonymous) @ extensionService.ts:369
e.fire @ event.ts:140
t._onExtHostProcessExit @ extensionHost.ts:430
(anonymous) @ extensionHost.ts:215
emitTwo @ events.js:126
emit @ events.js:214
__dirname.ChildProcess._handle.onexit @ internal/child_process.js:198
index.js:41 [uncaught exception]: Error: write EPIPE
onError @ index.js:41
(anonymous) @ index.js:160
emitOne @ events.js:116
emit @ events.js:211
window.onerror @ /Applications/Visual Studio Code.app/Contents/Resources/electron.asar/renderer/init.js:142
i.globals.onerror @ errorTelemetry.ts:79
index.js:44 Error: write EPIPE
    at _errnoException (util.js:1024)
    at WriteWrap.afterWrite [as oncomplete] (net.js:867)
onError @ index.js:44
(anonymous) @ index.js:160
emitOne @ events.js:116
emit @ events.js:211
window.onerror @ /Applications/Visual Studio Code.app/Contents/Resources/electron.asar/renderer/init.js:142
i.globals.onerror @ errorTelemetry.ts:79
events.js:183 Uncaught Error: write EPIPE
    at _errnoException (util.js:1024)
    at WriteWrap.afterWrite [as oncomplete] (net.js:867)

VS Code version: Code 1.26.0 (4e9361845dc28659923a300945f84731393e210d, 2018-08-13T16:20:44.170Z) OS version: Darwin x64 17.7.0

System Info
Item Value
CPUs Intel® Core™ i7-6700HQ CPU @ 2.60GHz (8 x 2600)
GPU Status 2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: enabled
rasterization: enabled
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
Load (avg) 3, 3, 3
Memory (System) 16.00GB (2.27GB free)
Process Argv /Applications/Visual Studio Code.app/Contents/MacOS/Electron
Screen Reader no
VM 0%
Extensions (22)
Extension Author (truncated) Version
vsc-material-theme-italicize Ser 0.0.14
better-comments aar 1.2.6
Bookmarks ale 9.0.3
react-pure-to-class-vscode ang 1.1.6
snapshot-tools asv 0.0.7
npm-intellisense chr 1.3.0
vscode-eslint dba 1.4.12
githistory don 0.4.2
gitlens eam 8.5.4
prettier-vscode esb 1.6.1
vscode-flow-ide gca 1.2.0
vscode-styled-components jpo 0.0.21
vscode-todo-parser min 1.9.1
atom-keybindings ms- 3.0.4
vsliveshare ms- 0.3.535
debugger-for-chrome msj 4.8.2
color-highlight nau 2.3.0
material-icon-theme PKi 3.5.2
polacode pnp 0.2.2
code-spell-checker str 1.6.10
vim vsc 0.16.0
quokka-vscode Wal 1.0.136

(24 theme extensions excluded)

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 54
  • Comments: 24 (5 by maintainers)

Commits related to this issue

Most upvoted comments

I’m having the same issue. It seems to be killing prettier and possible other extensions.

In my case the Go extension make the problem, but the Go extension author is microsoft.

It looks like the root cause is https://github.com/electron/electron/issues/13254. We have identified a simple workaround to avoid the crash.

❗️❗️❗️ Please verify this issue on all 3 platforms: windows, linux and mac.

To verify, you can use the following extension:

56387-0.0.1.vsix.zip

  • package.json:
{
    "name": "56387",
    "version": "0.0.1",
    "publisher": "alex",
    "engines": {
        "vscode": "^1.25.0"
    },
    "activationEvents": [
        "onCommand:extension.sayHello"
    ],
    "main": "./extension",
    "contributes": {
        "commands": [
            {
                "command": "extension.sayHello",
                "title": "Hello World"
            }
        ]
    }
}
  • extension.js:
const vscode = require('vscode');
const cp = require('child_process');

exports.activate = function(context) {
    let disposable = vscode.commands.registerCommand('extension.sayHello', function () {
        console.log(`in repro1`);
        const child = cp.spawn(`/node1`);
        child.stdin.write('hi standard in!');
    });
    context.subscriptions.push(disposable);
}

same issue here, the ruby-extension is the killer in my case…

Sorry about that! It looks like there are a few hiccups possibly caused by VSCode’s Electron update. A short list of apparently impacted extensions:

If you find other impacted extensions, please try to also reach out to them directly. I am not entirely sure at this point what is the root cause.

@ramya-rao-a you appear to understand the root cause, can you please explain it more https://github.com/Microsoft/vscode-go/issues/1845#issuecomment-412953676

This is most likely related to an issue with electron throwing SIGPIPE error when passing stdin to a badly spawned process

@alexandrudima My findings were similar to what @wingrunr21 is saying above.

@wingrunr21 In vscode-go we don’t need users to provide/configure the absolute paths. The extension figures out the path itself, makes sure the file exists and returns the absolute path of the file. If the file is not found, then the command is returned. That’s why my mitigation was checking for the absolute path.

The above mitigation works for https://github.com/electron/electron/issues/13254. I am still looking into if https://github.com/electron/electron/issues/13679 has any affect on vscode-go

@sanjcho Thanks for the tip! It was the same for me, disabling vscode-flow-ide fixed things. I uninstalled it and installed Flow Language Support instead.

@alexandrudima

In my investigations for vscode-ruby it appears to be when spawn is attempted to be run with a command that isn’t in the PATH and something is attempted to be piped to stdin. Since the command is invalid there’s no valid file descriptor and Electron bombs. Instead of returning ENOENT, SIGPIPE is triggered which brings down the entire extension host.

I’ve found two open Electron issues related to this: electron/electron#13254 and electron/electron#13679

As it is occurring within Electron, I haven’t found a way to prevent it from occurring at the extension level. vscode-go appears to have mitigated this by requiring the command be an absolute path prior to attempting to run it. That solution is a bit more problematic for me. I’m leaning on using a command -v check on POSIX compliant systems vs requiring users to configure absolute paths.

met the same, in my case disabling vscode-flow-ide extention made all working ok.