How to Debug a multi-threaded node-webkit application


I have an application where when my index.html is loaded by node-webkit it executes a run-server.js file:

    loadScript("run-server.js") - This will create a script element in the document set to the contents of the .js file given.

    global.serverProcess = ch.fork('server', [], {

      execPath: execPath,
      env: process.env,
      execArgv: ['--debug-brk'],

The run-server.js file uses the child_process fork function to create a new process for my server which listens for commands to be sent to localhost port 8100.

What I'm having an issue with is that I can setup a node-webkit configuration that allows me to debug my main application, includeing run-server.js with no issue.  But I cannot seem to connect the debugger to the child process that is being created in run-server.js.  

I saw this post ( but it looks like it is talking more about how to debug a node process and not node-webkit.  The difference I think being that the run-server.js is loaded independently in the index.html.

Any insights you have would be a appreciated.  I can share more code if needed, I just didn't want to overwhelm people with too much :


1 comment


I have an update on this after restructuring my code but I'll still having issues I could use advice on.

My code now does the following:

    Load a script called run-server.js

    if (!global.embeddedIpgServer) {

    global.embeddedIpgServer = require("./embeddedServer/server");

    var USB2ANY = require('./usb2any');

I'm trying to set a breakpoint in the usb2any file to debug.  It seems that by changing this code to be a node module that is loaded with a require instead of being a script that was directly loaded by index.html in the past I have lost the ability for Webstorm to set and hit breakpoints in the code.  I can use the node-webkit devtools to set and debug the code but this is less than ideal

So is there a way when running a node-webkit debug configuration to connect the debugger to the code loaded in the node.js context?



Please sign in to leave a comment.