You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: allow --inspect=localhost:0 to resolve hostnames (#34230)
## Summary
Node accepts hostnames in `--inspect=...`, `--inspect-port=...`, and
`inspector.open(port, host)`, resolving them via DNS. Deno's inspector
flag parser and `op_inspector_open` only accepted IP-literal hosts, so
`--inspect=localhost:0` failed at parse time.
- Resolve hostnames via `ToSocketAddrs` in `inspect_value_parser` and
`op_inspector_open`, preferring IPv4 results to match Node's resolver.
- Add `op_inspector_port`. The `process.debugPort` getter consults it
so userland sees the ephemeral port chosen by `--inspect=...:0`. An
explicit `process.debugPort = N` assignment still wins, matching
Node's mutable semantics.
- For `--inspect-port=N` used without `--inspect[-brk|-wait]`, Node
updates `process.debugPort` but does not start the inspector. Deno
doesn't surface `--inspect-port` as a runtime flag, so the node_shim
translator injects the equivalent `process.debugPort = N;` assignment
into the eval code used by `-p`/`-e`.
- Enables `parallel/test-inspector-port-zero.js` in the node_compat
config.
Closes denoland/orchid#142
## Test plan
- New unit test `inspect_value_parser_resolves_hostnames` in
`cli/args/flags.rs` covers `localhost:0`, `localhost:1234`, and
`localhost`.
- New unit tests in `libs/node_shim/lib.rs`
(`test_translate_inspect_port_injects_debug_port_for_print` and
`test_translate_inspect_port_does_not_inject_when_inspector_enabled`).
-
`tests/node_compat/runner/suite/test/parallel/test-inspector-port-zero.js`
now passes (verified across 5 consecutive runs).
- Existing inspector tests still pass:
`test-inspector-debug-end.js`, `test-inspector-has-idle.js`,
`test-inspector-promises.js`, `test-inspector-open.js`,
`test-inspector-open-coverage.js`,
`test-inspector-open-port-integer-overflow.js`.
- Existing inspector parser unit tests still pass:
`inspect_flag_parsing`, `inspect_wait`, `inspect_default_host`,
`inspect_publish_uid_flag_parsing`.
- `cargo clippy -p deno_node -p node_shim -p deno --bin deno --lib`
clean.
Co-authored-by: divybot <divybot@users.noreply.github.com>
Co-authored-by: Divy Srivastava <me@littledivy.com>
0 commit comments