vscode icon indicating copy to clipboard operation
vscode copied to clipboard

Electron's stdout disappears in VSCode DEBUG CONSOLE under Windows

Open TheLevenCreations opened this issue 10 years ago • 13 comments

Hi,

VSCode is so great and I have used it to develop electron applications for several months. Thank you guys for developing such great tool! :-)

My development environments are OSX and Windows. I just found an inconsistent behaviour between them. Would you like to take a look, please? Thanks.

My launch.json file is as follows, which is used to launch electron app using electron executable instead of node executable.

        {
            "name": "sample app",
            "type": "node",
            "request": "launch",
            "program": "${workspaceRoot}/test/app`.js",
            "stopOnEntry": false,
            "args": [
            ],
            "cwd": "${workspaceRoot}",
            "runtimeExecutable": "${workspaceRoot}/electron.exe",  //  <----it points to Electron.app/Contents/MacOS/Electron under OSX
            "runtimeArgs": [
            ],
            "env": {
            },
            "sourceMaps": true,
            "outDir": null
        },

There are some debug prints in app.js:

// app.js
console.log('this is for debugging');

Then I press F5 to launch it. It works well under OSX: 'this is for debugging' message is dumped into DEBUG CONSOLE in vscode. However, there is nothing in DEBUG CONSOLE under Windows platform - except the first message indicating the debugging started:

c:\VisualStudioCode\electron.exe --debug-brk=7145 -test\app.js 

VS code is at latest 0.10.8 version(this issue also found in 0.10.7). Both Windows 7 64bit and 10 64bit have this problem.

Did I miss something? Any suggestions/tips/workarounds, please let me know. I've been in this trouble for serveral days. Thanks very much.

TheLevenCreations avatar Feb 09 '16 13:02 TheLevenCreations

By the way, if I remove the line "runtimeExecutable": "${workspaceRoot}/electron.exe" and using node.exe instead, everything works fine.

TheLevenCreations avatar Feb 09 '16 14:02 TheLevenCreations

Having the same issue (as per the title). Only stderr is showing on the Debug Console. Seems to have been introduced with 1.9.0.

Here is the launch config I use:

        {
            "type": "node2",
            "request": "launch",
            "name": "Launch Program",
            "program": "${workspaceRoot}\\server\\main.js",
            "cwd": "${workspaceRoot}",
            "sourceMaps": true,
            "smartStep": true,
            "internalConsoleOptions": "openOnSessionStart"
        }

nsgundy avatar Feb 06 '17 16:02 nsgundy

@nsgundy does it help if you switch the debug type from 'node2' to 'node'?

weinand avatar Feb 06 '17 16:02 weinand

@nsgundy does it help if you switch the debug type from 'node2' to 'node'?

Yes, seems fine with "type": "node".

nsgundy avatar Feb 06 '17 18:02 nsgundy

@nsgundy you are seeing a different problem as @TheLevenCreations because you are not using Electron but the new experimental node debugger 'node2'. Please file a separate issue for this.

weinand avatar Feb 06 '17 21:02 weinand

I am having the same problem but with "node":

    {
      "type": "node",
      "request": "launch",
      "name": "Launch Program",
      "program": "${workspaceRoot}/bin/task_runner.js",
      "cwd": "${workspaceRoot}",
      "env": {
        "NODE_ENV": "development"
      }
    }

Only stderr is shown:

node --inspect=25779 --debug-brk bin/task_runner.js -u tarot.com 
Debugger listening on port 25779.
Warning: This is an experimental feature and could change at any time.
Debugger attached.

I am using 1.10.0-insiders.

With 1.9.0 it works perfectly.

Update: Didn't see https://github.com/Microsoft/vscode/issues/19750

hrgui avatar Feb 06 '17 23:02 hrgui

@hrgui, the output of your debugging session does indicate that you are running with the node2 debug adaptor (--inspect was passed). Is it possible that you launched with node2 and then while the session was still running, changed to node and clicked restart? To change the debug adapter you do seem to have to stop the debugging session.

@weinand Will open a new issue, thank you.

nsgundy avatar Feb 07 '17 00:02 nsgundy

Please note: 'node2' is gone in Insider!

Background: for the February milestone we are planning to provide a unified Node Debugging Experience by merging 'node' and 'node2' into one debugger and making the switching automatic.

@hrgui since you are using the Insider release, you can see a preview of the unified Node Debugging Experience already today (and the console output 'experimental' is an indication that VS Code has picked 'node2' for you). If you do not want to let VS Code choose the debug adapter, you can override this by setting the protocol attribute to legacy (for 'node) or v8-inspector (for 'node2').

weinand avatar Feb 07 '17 09:02 weinand

The original issue has been fixed in Electron:

2017-02-07_11-03-36

weinand avatar Feb 07 '17 10:02 weinand

I've been encountering this issue lately in VS Code 1.13.1 with Electron 1.7.2. I put a console.log statement in my main process script, and the Debug Console outputs nothing.

craxal avatar Jun 23 '17 21:06 craxal

@weinand @craxal me and my team are getting this behavior since we changed from legacy to inspector. It seems to be working in OSX but not in Windows. No outputs to the Debug Console.

We're using vscode 1.16.1 x64, node 7.9.0 & electron 1.7.6.

robertohuertasm avatar Sep 18 '17 14:09 robertohuertasm

I've tested the ia32 version and it presents the same behavior. Insiders, both x64 and ia32, too.

robertohuertasm avatar Sep 18 '17 14:09 robertohuertasm

@robertohuertasm since this issue has been closed and you have switched the protocol to "inspector", your issue is unrelated and you should create a new issue for it with detailed and reproducible steps.

weinand avatar Sep 18 '17 20:09 weinand