Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sails debug command not working in Sails.js

I am creating my first sails.js app. When I tried

sails debug

I'm getting the following error on my command prompt

Debugger listening on port 5858
info: Starting app...

error: Grunt :: Error: listen EADDRINUSE
    at exports._errnoException (util.js:746:11)
    at Agent.Server._listen2 (net.js:1129:14)
    at listen (net.js:1155:10)
    at Agent.Server.listen (net.js:1240:5)
    at Object.start (_debugger_agent.js:20:9)
    at startup (node.js:86:9)
    at node.js:814:3

To get the PID of the process using port:5858, I tried running

C:\Windows\system32>netstat -a -n -o

but unfortunately there is no process bound to port 5858. Am I missing something here?

I'm using Windows 8.1 with node.js v0.12.0 and sails.js 0.11.0

like image 462
Jaseem Abbas Avatar asked Apr 17 '15 06:04

Jaseem Abbas


2 Answers

My server uses node 0.10.38 with sails because of some weird unfixed grunt thing with 11+. Haven't pulled up this issue in a while, but it looks like there's new activity... check out this comment in particular, which explains the issue and a possible fix (direct quote):

Possible Solution:

Looking at the options for child_process.fork, the --debug flag is being passed down to the child upon exiting the womb i.e. running sails debug :

// ./node_modules/sails/bin/sails-debug.js

// Spin up child process for Sails
Womb.spawn('node', ['--debug', pathToSails, 'lift'], {
    stdio: 'inherit'
});

setting options.execArgv to an empty array removes the flag and allows the process to continue:

// ./node_modules/sails/lib/hooks/grunt/index.js
var child = ChildProcess.fork(
  path.join(__dirname, 'grunt-wrapper.js'),
  [
    taskName,
    '--pathToSails='+pathToSails,

    '--gdsrc='+ pathToSails + '/node_modules'
  ],
  {
    silent: true,       
    stdio: 'pipe',
    execArgv: []
  }
);
like image 123
Hypaethral Avatar answered Nov 16 '22 05:11

Hypaethral


It seems like a bug in Sails. You can apply the fix your self by replacing your Sails' file:

./node_modules/sails/lib/hooks/grunt/index.js

with the contents of the following:

https://raw.githubusercontent.com/balderdashy/sails/88ffc0ed9949f8c74ea390efb5610b0e378fa02c/lib/hooks/grunt/index.js

This is the file that will be in the Sails' release v12.

like image 2
Pierre Avatar answered Nov 16 '22 05:11

Pierre