为什么我的nodejs程序与--inspect-brk选项不同地运行

时间:2018-10-18 14:23:50

标签: node.js google-chrome-devtools dbus

我有一个简单的nodejs程序,尝试使用dbus-network-manager通过DBus连接到NetworkManager。不幸的是,我无法使用chrome:// inspect对其进行调试,因为它在调试器中的行为有所不同。

代码如下:

const NetWorkManager = require('dbus-network-manager').connect()
.then(nm => {
    // this branch taken when run with or without --inspect option
    console.log ('connected successfully');
})
.catch(err => {
    // this branch taken when node launched with --inspect-brk option
    console.log ('failed to connect, error was: ' + err);
})

这是它在3种不同情况下的运行方式:

$ node app.js
DBus test app running in development mode connected successfully

node --inspect app.js
Debugger listening on ws://127.0.0.1:9229/3fcf6bd4-f6fa-4bf2-8dcd-30c8fdcd14b8
For help see https://nodejs.org/en/docs/inspector
DBus test app running in development mode
connected successfully

node --inspect-brk app.js
Debugger listening on ws://127.0.0.1:9229/e935e8b4-0d78-4ad0-a5c1-894e5631c8fa
For help see https://nodejs.org/en/docs/inspector
Debugger attached.
DBus test app running in development mode
failed to connect, error was: Error: No introspectable

考虑到--inspect似乎可以正常运行,我可以解决该问题,但是我很想知道为什么会这样。

谢谢!

0 个答案:

没有答案