Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Reapply "debug: Wait 50ms before running the main module"
Browse files Browse the repository at this point in the history
This reapplies commit c781f17
This reverts commit 0022477
  • Loading branch information
isaacs committed Mar 29, 2012
1 parent cda3b6f commit 8a15147
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions src/node.js
Expand Up @@ -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');
Expand Down

0 comments on commit 8a15147

Please sign in to comment.