summaryrefslogtreecommitdiff
path: root/src/node.js
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2012-03-28 19:40:54 -0700
committerisaacs <i@izs.me>2012-03-28 19:41:29 -0700
commit8a15147bc53849417f8737dd873877d497867c9f (patch)
tree477010e6ec7ea0a4bd960dd495c16e493c8bb0f6 /src/node.js
parentcda3b6ff52e78b61c25f1e04ff9f6f5f5046dec0 (diff)
downloadnode-new-8a15147bc53849417f8737dd873877d497867c9f.tar.gz
Reapply "debug: Wait 50ms before running the main module"
This reapplies commit c781f17742170f2e127f9ee6652c56b406c30586 This reverts commit 00224771e32e4d051e5ea33b7e854f0031359912
Diffstat (limited to 'src/node.js')
-rw-r--r--src/node.js29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/node.js b/src/node.js
index ade49aa1f1..3322df6d25 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');