node icon indicating copy to clipboard operation
node copied to clipboard

util.inspect({level: "info"}) exits the debug session

Open learnerbyheart opened this issue 10 years ago • 43 comments

When debugging in node.js 5.3.0 the script bug.js

var util = require('util');
util.inspect({level: "info "});
console.log("Test");

with node debug bug.js, the debugging session exits. I tried the same in node.js 4.2.4 and it doesn't. When debugging the difference in lib/util.js, line 324 in 5.3.0 looks like this:

var promiseInternals = inspectPromise(value);

and line 319 in 4.2.4 looks like:

var promiseInternals = value instanceof Promise && inspectPromise(value);

As value is not an instance of Promise, inspectPromise(value) is called in 5.3.0. Then inspectPromise calls ensureDebugIsInitialized() which on the other hand calls require('vm').runInDebugContext('Debug'). This causes the debugging session to exit. The issue was tested in Ubuntu 14.04 LTS.

learnerbyheart avatar Dec 27 '15 20:12 learnerbyheart

I have no idea either offhand what the change was. You could git bisect it I suppose.

mscdex avatar Jan 14 '16 06:01 mscdex

i'm experiencing this issue when debugging my expressjs application via node-debug (node 5.4.1)

express logs a value, the formatter tries to inspect the value via inspectPromise, which calls ensureDebugIsInitialized and my debugging session is gone

any workarounds?

daef avatar Jan 20 '16 15:01 daef

I also experienced this problem on Windows 10. Downgrading to Node 4.2.4 (and then installing the latest NPM to avoid MAX_PATH issues) worked around the issue for me.

I bet this is the same problem we are seeing in #4815

MylesBorins avatar Jan 22 '16 17:01 MylesBorins

From what I've been able to investigate @TheAlphaNerd ... I tend to agree.

jasnell avatar Jan 23 '16 01:01 jasnell

Just to confirm I have experienced exactly same behaviour (node 4.2.6) as @AdamAndersonFalafelSoftware. Tested in NTVS and Visual studio code.

edvinv avatar Jan 26 '16 14:01 edvinv

I have a similar problem using Node (4.2.6) under OSX (10.10.5). If I use WebStorm to debug, the process silently exits with code 139. If I run the app through bash with the --debug flag it throws "Segmentation fault: 11" and exits. In production everything works fine.

Thanks!

imaustink avatar Feb 02 '16 21:02 imaustink

I'm seeing this exact behavior as well on Node 4.2.6 on Windows, via the azure-storage package.

pprice avatar Feb 03 '16 23:02 pprice

@pprice Downgrade to 4.2.4. As I reported above, the debugger works at that version

I can confirm the issue is resolved by downgrading to 4.2.4.

tcf909 avatar Feb 05 '16 01:02 tcf909

Sadly downgrading is not an option for everyone.

atom0s avatar Feb 05 '16 02:02 atom0s

Downgrade worked - thanks @AdamAndersonFalafelSoftware. I can also confirm for OSX 10.11. I'm hoping 4.2.8 will have the fix? Bit of pain telling coworkers they have to use a specific version to debug.

pprice avatar Feb 05 '16 03:02 pprice

Similar behavior described by @imaustink with Webstorm under OS X with 4.2.6. Node 4.2.2 is working OK.

guidoman avatar Feb 05 '16 10:02 guidoman

There is a fix in, hoping to have it released for ya'll soon after the next security release

https://github.com/nodejs/node/pull/4819

MylesBorins avatar Feb 05 '16 10:02 MylesBorins

Thanks @TheAlphaNerd!

In the mean time, for folks stumbling upon this, I can confirm that downgrading to 4.2.4 resolves this for folks seeing issues in their Sails apps (thanks @chirag200666 and @LongSteve!)

mikermcneil avatar Feb 05 '16 12:02 mikermcneil

The fix is now in master, you should expect this to see it in a release in the next 2 - 3 weeks on v4 and v5.

MylesBorins avatar Feb 05 '16 23:02 MylesBorins

Thanks for your efforts @TheAlphaNerd it is greatly appreciated.

atom0s avatar Feb 06 '16 00:02 atom0s

The fix is now released in v5.6.0. Expect LTS next week

MylesBorins avatar Feb 09 '16 20:02 MylesBorins

Still broken in 4.3.0 with the following code in WebStorm 11.03 debug

        var jsonData = jsonfile.readFileSync(fromFile);
        log.trace(jsonData);

The trace (or info levels etc) is dumped, but the debug session is exited afterwards.

Smurf-IV avatar Feb 11 '16 09:02 Smurf-IV

The comment just above yours mentioned already that it will be fixed at a later time for LTS.

atom0s avatar Feb 11 '16 09:02 atom0s