Repository navigation
fix: increment inspector port for IPv6 hosts - #2636
Conversation
|
Can you supply a good (authoritative and easy to read) reference for Bracketed IPv6 host addresses? The regular expression is pretty opaque. A brief comment explaining the point of the regexp is needed. |
| test('when --inspect uses an IPv6 host then bump port', (t) => { | ||
| const { spawnSpy } = makeSpies(t); | ||
| const program = makeProgram(); | ||
| process.execArgv = ['--inspect=[::1]', '--inspect=[::1]:100']; |
There was a problem hiding this comment.
Is having multiple inspect ports in a single call a valid use of the CLI?
I expected these to be in separate calls (and separate tests).
There was a problem hiding this comment.
Good point. I combined the two cases to keep the test small, but separate tests would reflect actual usage better. I'll split them into an IPv6 host-only case and an IPv6 host-with-port case.
|
Thanks for the review. RFC 3986, section 3.2.2 specifies square brackets around IPv6 host literals. For I'll add a brief comment explaining that the host pattern matches either a bracketed IPv6 address or a hostname/IPv4 address without colons, with the optional port handled separately. |
|
I reworked the comments to remind myself what is happening, simpler than sending you lots of suggestions or replacements. (First time I have done a commit direct to a PR!) |
|
Released in Commander v15.1.0 |
Commander increments the Node inspector port when spawning an executable subcommand, but the host patterns exclude colons. Bracketed IPv6 hosts therefore bypass the incrementer, and the child tries to use the parent's port.
For example, running
node --inspect=[::1]:19340 tests/fixtures/inspect.js subondevelopprintsStarting inspector on ::1:19340 failed: address already in use. With this fix, the child starts its inspector on[::1]:19341.Recognise bracketed IPv6 hosts in the existing shared parser, both with an explicit port and with the default port. Add separate regressions for IPv6 hosts with and without an explicit port using the existing executable-subcommand test helper. No dependencies or API changes.
Validation:
pnpm checkpasses, including JavaScript and TypeScript checks, ESLint, and Prettier.Suggested changelog entry: Fix incrementing the Node inspector port for IPv6 hosts when spawning executable subcommands.
Prepared with AI assistance. The complete diff was reviewed and the checks above were run before submission.