Skip to content

Commit

Permalink
feat!: change default --host to 127.0.0.1
Browse files Browse the repository at this point in the history
Node.js v17 changed its DNS resolution defaults, and it can cause
localhost to resolve to IPv6 instead of IPv4. Inspector, on the other
hand, responds only to 127.0.0.1 by default. So changing the default for
--host to 127.0.0.1 seems appropriate. Marking as breaking in case
anyone is relying on `localhost` resolving to IPv6 on newer Node.js
versions.
  • Loading branch information
mmarchini committed Jul 11, 2023
1 parent 96a08b0 commit 1b94e27
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bin/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function getHostPortFromArgs({ pid, host, port }) {
startDebugger(pid);
}

return { host: host || 'localhost', port: port || 9229 };
return { host: host || '127.0.0.1', port: port || 9229 };
}

function getStreamFromArgs({ file }) {
Expand Down
2 changes: 1 addition & 1 deletion test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class FakeStream {
async function runCommandWithClient(run, port, ...args) {
const stream = new FakeStream();

const client = new Client('localhost', port);
const client = new Client('127.0.0.1', port);
await client.connect();

await run(client, stream, ...args);
Expand Down
6 changes: 3 additions & 3 deletions test/test-inspector-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ test('attach to existing process', (t) => {
f.on('inspectorReady', async ({ port }) => {
t.ok(port > 0);

const client = new Client('localhost', port);
const client = new Client('127.0.0.1', port);
try {
await client.connect();
await client.disconnect();
Expand All @@ -27,7 +27,7 @@ test('send message', (t) => {
f.on('inspectorReady', async ({ port }) => {
t.ok(port > 0);

const client = new Client('localhost', port);
const client = new Client('127.0.0.1', port);
try {
await client.connect();
t.deepEqual(await client.post('Profiler.enable'), {});
Expand All @@ -46,7 +46,7 @@ test('receive message', (t) => {
f.on('inspectorReady', async ({ port }) => {
t.ok(port > 0);

const client = new Client('localhost', port);
const client = new Client('127.0.0.1', port);
try {
await client.connect();
await client.post('Debugger.enable', {});
Expand Down

0 comments on commit 1b94e27

Please sign in to comment.