pgriess / node-webworker

A WebWorkers implementation for NodeJS
BSD 3-Clause "New" or "Revised" License
646 stars 84 forks source link

Debug Port #4

Closed twittner closed 14 years ago

twittner commented 14 years ago

I'd like to ask if you could maybe provide a way to allow starting web workers with debug ports, e.g.:

diff --git a/lib/webworker.js b/lib/webworker.js
index 95f7489..60d5701 100644
--- a/lib/webworker.js
+++ b/lib/webworker.js
@@ -47,7 +47,7 @@ var numWorkersCreated = 0;
 //
 // Each worker communicates with the master over a UNIX domain socket rooted
 // in SOCK_DIR_PATH.
-var Worker = function(src) {
+var Worker = function(src, debugPort) {
     var self = this;

     // The timeout ID for killing off this worker if it is unresponsive to a
@@ -109,13 +109,15 @@ var Worker = function(src) {
     // and away we go.
     var start = function() {
         srv.addListener('listening', function() {
+            const dbg = debugPort ? ["--debug=" + debugPort] : []
             cp = child_process.spawn(
                 process.argv[0],
+                dbg.concat(
                 [
                     path.join(__dirname, 'webworker-child.js'),
                     sockPath,
                     'file://' + src
-                ],
+                ]),
                 undefined,
                 [0, 1, 2]
             );
pgriess commented 14 years ago

Fixed in 1c25095a346bf2122d683107a0e5ea87f4482a6d.