Skip to content

error Error: listen EADDRINUSE :::5858 when using node debug #533

@alexklibisz

Description

@alexklibisz

I'm using node 6.0.0 and commander ^2.9.0. I'm trying to use the built-in node debugger to inspect at some breakpoints.

Case 1: If I run a script that doesn't use commander, it works:

src/cli/works.js:

var x = 5;
setTimeout(() => {
  debugger;
  console.log('world');
}, 1000);
console.log('hello');
$ node debug src/cli/works.js 
< Debugger listening on port 5858
connecting to 127.0.0.1:5858 ... ok
break in src/cli/works.js:1
> 1 var x = 5;
  2 setTimeout(() => {
  3   debugger;
debug> cont
< hello
break in src/cli/works.js:3
  1 var x = 5;
  2 setTimeout(() => {
> 3   debugger;
  4   console.log('world');
  5 }, 1000);
debug> cont
< world
debug> 

Case 2: If I run my commander script without debug, it also works:

src/cli/cli.js

const
  cli = require('commander'),
  pkg = require('../../package.json');

cli
  .version(pkg.version)
  .command('grid', 'creates grid-style visualization')
  .parse(process.argv);

src/cli/cli-grid.js

debugger;
console.log('grid');
$ node src/cli/cli.js grid
grid

Case 3: But if I run a script with the commander and the debug option, it gives the following error:

$ node debug src/cli/cli.js grid
< Debugger listening on port 5858
connecting to 127.0.0.1:5858 ... ok
break in src/cli/cli.js:1
> 1 const
  2   cli = require('commander'),
  3   pkg = require('../../package.json');
debug> cont
< Error: listen EADDRINUSE :::5858
<     at Object.exports._errnoException (util.js:896:11)
<     at exports._exceptionWithHostPort (util.js:919:20)
<     at Agent.Server._listen2 (net.js:1246:14)
<     at listen (net.js:1282:10)
<     at Agent.Server.listen (net.js:1378:5)
<     at Object.start (_debug_agent.js:21:9)
<     at startup (node.js:85:44)
<     at node.js:444:3
debug> cont
debug> cont
debug> cont

So it seems that there's some sort of issue being cause by using the debugger and commander at the same time. I've searched other issues, but found nothing directly relevant. Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions