Vscode: Cannot debug Electron sample using "Node.js: Electron Main" launch.json template

Created on 5 Mar 2017  路  13Comments  路  Source: microsoft/vscode

Description

I am unable to debug the Electron Quick Start sample in VS Code using the "Node.js: Electron Main" _launch.json_ configuration template.

Although the code appears to stop at placed breakpoints, there is no call stack displayed. Instead the following error is displayed:

"No call stack available (vscode_backtrace: Internal error: TypeError: undefined is not a function)"

Note: about once in every blue moon of starting debug, it actually works(!) This issue is temperamental, but definitely on the side of 'not working' much much more than it does work. I did not notice anything different during the times it does work.

Version info

  • VSCode Version: 1.10.1
  • OS Version: Windows 10 Pro (x64) 1607 (Build 14393.693)
  • Node.js version: v6.9.2
  • electron/electron-quick-start repository: current head of master as of 2017-03-05 (f8ae670c)

Steps to Reproduce

  1. Clone electron/electron-quick-start repository
  2. npm install
  3. Open repository folder in VSCode
  4. Debug tab > Configuration drop-down > Add configuration
  5. In _launch.json_ editor click Add Configuration... button > Node.js: Electron Main
    image

  6. Add a breakpoint anywhere in _main.js_ (e.g., line 16: mainWindow = new BrowserWindow(...))

  7. Start debugging using the "Electron Main" configuration

Expected

  • Stop at breakpoint placed in _main.js_ and line is highlighted
  • Debug tab shows the call stack

Actual

  • Stop at breakpoint placed in _main.js_ but line is not highlighted
  • Debug tab shows an error: "No call stack available (vscode_backtrace: Internal error: TypeError: undefined is not a function)"

image

_launch.json_

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Electron Main",
            "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
            "windows": {
                "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
            },
            "program": "${workspaceRoot}/main.js",
            "protocol": "legacy"
        }
    ]
}
bug debug verified

Most helpful comment

I麓m having exactly the same problem using the latest Electron version, but I was able to get breakpoints running by using an older electron version (1.5.1).

In my tests, the issue starts with electron version 1.6.0, so the temporary workaround is to clean the node_modules directory and modify the dependency version from "^1.4.1" to "1.5.1".

All 13 comments

I麓m having exactly the same problem using the latest Electron version, but I was able to get breakpoints running by using an older electron version (1.5.1).

In my tests, the issue starts with electron version 1.6.0, so the temporary workaround is to clean the node_modules directory and modify the dependency version from "^1.4.1" to "1.5.1".

Thanks @psevestre, Electron 1.5.x does indeed work without any other changes. 馃槂
The issue must be, as you say, something to do with Electron 1.6.x on wards.

Yes, i upgraded electron to 1.6.2 same error: "No call stack available (vscode_backtrace: Internal error: TypeError: undefined is not a function)"

So for the time being I suggest to stick to Electron 1.5.1 until we've figured out what the problem is.

The v8 version used in Electron 1.6 broke some assumption of code injection in node-debug (legacy).
So this is not a regression in VS Code 1.10.x but an incompatibility of node-debug (legacy) and recent versions of v8. I've removed the assumption.

Please try tomorrow's insiders build

I cannot debug with/without protocol "legacy" in Launch.json with Electron 1.6 on VSCode version below

Version 1.11.0-insider
Commit dd197f19ddad6f8fa960c5f330fb7182c2321de3
Date 2017-03-13T07:11:52.101Z
Shell 1.4.6
Renderer 53.0.2785.143
Node 6.5.0

@wip0 I do not understand what you want to say with your comment.

I've fixed this issue and it is available in the latest Insider
Commit: 8cd6b5830957e101a7b4fb63b6c6dbbd1640ed2a
Date: 2017-03-14T08:18:08.786Z

@weinand I updated my above comment.

BTW, I didn't sure which version fix this issue. So, I posted my VSCode version.
I am waiting for getting the new version.

@weinand, just tried using 1.11.0-insider and debugging the Electron (1.6.x) main process now works!
Thanks 馃憤 馃槃

image

@weinand A second thanks! (And a second confirmation.) This fix comes just in the nick of time! [And writing that phrase made me curious... http://www.phrases.org.uk/meanings/in-the-nick-of-time.html]

@JonMarbach thanks for the info about the origin of "in the nick of time". Very interesting.

@weinand Thank you so much, it also works on my end!

Added "verified" label because it was verified by multiple users.

Was this page helpful?
0 / 5 - 0 ratings