Vscode: Extension host terminated unexpectedly after 1.26.0 update

Created on 14 Aug 2018  ·  24Comments  ·  Source: microsoft/vscode

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(R) Core(TM) 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)


bug electron-2-update important mac verified

Most helpful comment

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

All 24 comments

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

The biggest problem for me was the vim extension. When the extension host went down it would leave me in command mode, but none of the commands would work.

Anyway, I installed the previous release and it auto-updated to 1.26.0 when i accidentally restarted Code. It seems to be working ok again.

met the same issue

met the same issue

ERR An unknown error occurred. Please consult the log for more details.
/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:1398   ERR Invalid argument: Error: Invalid argument
    at t._validatePosition (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:502:878)
    at t._getWordRangeAtPosition (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:503:187)
    at Object.getWordRangeAtPosition (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:500:806)
    at Object.definitionLocation (/Users/joseph/.vscode/extensions/ms-vscode.go-0.6.87/out/src/goDeclaration.js:15:30)
    at GoSignatureHelpProvider.provideSignatureHelp (/Users/joseph/.vscode/extensions/ms-vscode.go-0.6.87/out/src/goSignature.js:30:32)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:744:186
    at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:110:323
    at new n.Class.derive._oncancel (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:84:776)
    at Object.t.asWinJsPromise (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:110:286)
    at e.provideSignatureHelp (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:744:140)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:754:663
    at e._withAdapter (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:747:177)
    at e.$provideSignatureHelp (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:754:625)
    at e._doInvokeHandler (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:671:983)
    at e._invokeHandler (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:671:701)
    at e._receiveRequest (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:670:767)
    at e._receiveOneMessage (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:670:536)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:669:452
    at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:672:575
    at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:96:903
    at e.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:98:218)
    at a (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:162:713)
    at Socket._socketDataListener (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:162:932)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at Pipe.onread (net.js:594:20)

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

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

@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.

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

@mickeygo Yea they are aware of the issue: https://github.com/Microsoft/vscode-go/issues/1845

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

Thank you for looking into it. This seems like a difficult one to dig into

Adding "Candidate" label just so that this shows up in our discussion round.

@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.

@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

@ramya-rao-a ah, that makes sense. That auto detection is a problem I'm still trying to solve as a lot of Ruby environments are configured via shell functions and can vary by directory. That's why I proposed checking via command -v

Updated yesterday. None of eslint, prettier, nor gitlens work.
Downloaded the version from June to get work done today.
Works great. https://code.visualstudio.com/updates/v1_25

A minimal repro:

const child = cp.spawn(`node1`);
child.stdin.write('hi standard in!');

And a minimal fix from an extension would be to always check child.pid before using stdin:

const child = cp.spawn(`node1`);
if (child.pid) {
  child.stdin.write('hi standard in!');
}

I have the same issue with the Python extension after 1.26.0 update:

t.log @ /opt/visual-studio-code/resources/app/out/vs/workbench/workbench.main.js:272
/opt/visual-studio-code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] Failed to get interpreter information for '/home/user/.local/share/virtualenvs/webapp-Ab5ma23j/bin/python' SyntaxError: Unexpected token / in JSON at 
position 0
    at JSON.parse (<anonymous>)
    at PythonExecutionService.<anonymous> (/home/user/.vscode/extensions/ms-python.python-2018.7.1/out/client/common/process/pythonProcess.js:42:35)
    at Generator.next (<anonymous>)
    at fulfilled (/home/user/.vscode/extensions/ms-python.python-2018.7.1/out/client/common/process/pythonProcess.js:12:58)
    at <anonymous>

t.log @ /opt/visual-studio-code/resources/app/out/vs/workbench/workbench.main.js:272
/opt/visual-studio-code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] Summary:
/opt/visual-studio-code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host]% 19 parseable documents found
/opt/visual-studio-code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host]% 324 CSS class definitions found
/opt/visual-studio-code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host]% 102 unique CSS class definitions found
/opt/visual-studio-code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host]% 1 failed attempts to parse. List of the documents:
/opt/visual-studio-code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] /home/user/Projects/latest/srv_webapp/app/static/css/styles.css
/opt/visual-studio-code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] Failed to get interpreter information for '/home/user/.local/share/virtualenvs/webapp-Ab5ma23j/bin/python' SyntaxError: Unexpected token / in JSON at position 0
    at JSON.parse (<anonymous>)
    at PythonExecutionService.<anonymous> (/home/user/.vscode/extensions/ms-python.python-2018.7.1/out/client/common/process/pythonProcess.js:42:35)
    at Generator.next (<anonymous>)
    at fulfilled (/home/user/.vscode/extensions/ms-python.python-2018.7.1/out/client/common/process/pythonProcess.js:12:58)
    at <anonymous>

t.log @ /opt/visual-studio-code/resources/app/out/vs/workbench/workbench.main.js:272
/opt/visual-studio-code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] Python Extension: display.refresh TypeError: Cannot read property 'version' of undefined
    at InterpreterService.<anonymous> (/home/user/.vscode/extensions/ms-python.python-2018.7.1/out/client/interpreter/interpreterService.js:135:44)
    at Generator.next (<anonymous>)
    at fulfilled (/home/user/.vscode/extensions/ms-python.python-2018.7.1/out/client/interpreter/interpreterService.js:13:58)
    at <anonymous>

t.log @ /opt/visual-studio-code/resources/app/out/vs/workbench/workbench.main.js:272
/opt/visual-studio-code/resources/app/out/vs/workbench/workbench.main.js:3213 Extension host terminated unexpectedly. Code:  null  Signal:  SIGPIPE

w._onExtensionHostCrashed @ /opt/visual-studio-code/resources/app/out/vs/workbench/workbench.main.js:3213
/opt/visual-studio-code/resources/app/out/vs/workbench/workbench.main.js:2386 Extension host terminated unexpectedly.

t.onDidNotificationChange @ /opt/visual-studio-code/resources/app/out/vs/workbench/workbench.main.js:2386

Visual Studio Code (binary, stable)
Version: 1.26.0-3
OS: Linux
Electron: 2.0.5
Chrome: 61.0.3163.100
Node.js: 8.9.3
V8: 6.1.534.41
Arch: x64

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);
}

@alexandrudima After 20 minutes of testing, I can confirm that provided patch so far fixes the issue. Tested on Arch Linux OS with the official VSCode binary. Thanks a lot!

The vscode-go update on my Mac today, now it works fine.

@mickeygo @alexandrudima can anyone help me, I can't figure out how to implement this update. Thanks!

@Kevin8428 I mean that now the extension vscode-go update to 0.6.88 version and it will work fine on Mac, does not need to change the config file. I don't know other extensions. Thanks !

ahh same! thanks!

Was this page helpful?
0 / 5 - 0 ratings