Skip to content

Calling inspector.open() if the inspector is already available makes inspector.url() give a bad address #33012

Closed
@connor4312

Description

@connor4312
  • Version: v12.14.1
  • Platform: win32
  • Subsystem: Inspector

What steps will reproduce the bug?

  1. Create a script foo.js with:

    const inspector = require('inspector');
    console.log(inspector.url());
    inspector.open(0, undefined, false);
    console.log(inspector.url());
  2. Run node foo.js ✔️

    undefined
    Debugger listening on ws://127.0.0.1:37569/25b0bbd1-1b2d-45ab-bcb5-2e509196df2a
    For help, see: https://nodejs.org/en/docs/inspector
    ws://127.0.0.1:37569/25b0bbd1-1b2d-45ab-bcb5-2e509196df2a
    
  3. Run node --inspect foo.js

    Debugger listening on ws://127.0.0.1:9229/f72b422b-dde6-4d57-a507-86f4b7faf919
    For help, see: https://nodejs.org/en/docs/inspector
    ws://127.0.0.1:9229/f72b422b-dde6-4d57-a507-86f4b7faf919
    ws://127.0.0.1:0/f72b422b-dde6-4d57-a507-86f4b7faf919
    

How often does it reproduce? Is there a required condition?

100%

What do you see instead? / What is the expected behavior?

It seems like calling inspect() again will silently "overwrite" the existing run with an unresolved port 0. I would expect any of the following as 'good' behavior:

  • An error is thrown (if we can't open the inspector on the new port)
  • The port is changed to the new address
  • or the inspector.url() is unaffected (no-op)

Additional information

Ref: microsoft/vscode#95128

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions