diff options
author | isaacs <i@izs.me> | 2012-03-20 19:46:36 -0700 |
---|---|---|
committer | isaacs <i@izs.me> | 2012-03-20 19:46:36 -0700 |
commit | c781f17742170f2e127f9ee6652c56b406c30586 (patch) | |
tree | 555334236ee623b93b87d037a22256f825b233ba /src/node.js | |
parent | 81cd3a3cd6204adbf645bd0538f794c1414511ed (diff) | |
download | node-c781f17742170f2e127f9ee6652c56b406c30586.tar.gz |
debug: Wait 50ms before running the main module
Diffstat (limited to 'src/node.js')
-rw-r--r-- | src/node.js | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/node.js b/src/node.js index 52467a69b..d0cbc4042 100644 --- a/src/node.js +++ b/src/node.js @@ -89,10 +89,31 @@ } var Module = NativeModule.require('module'); - // REMOVEME: nextTick should not be necessary. This hack to get - // test/simple/test-exception-handler2.js working. - // Main entry point into most programs: - process.nextTick(Module.runMain); + + if (global.v8debug && + process.execArgv.some(function(arg) { + return arg.match(/^--debug-brk(=[0-9]*)?$/); + })) { + + // XXX Fix this terrible hack! + // + // Give the client program a few ticks to connect. + // Otherwise, there's a race condition where `node debug foo.js` + // will not be able to connect in time to catch the first + // breakpoint message on line 1. + // + // A better fix would be to somehow get a message from the + // global.v8debug object about a connection, and runMain when + // that occurs. --isaacs + + setTimeout(Module.runMain, 50); + + } else { + // REMOVEME: nextTick should not be necessary. This hack to get + // test/simple/test-exception-handler2.js working. + // Main entry point into most programs: + process.nextTick(Module.runMain); + } } else { var Module = NativeModule.require('module'); |