From 3a1c2dd055859d74ec795876f511f865fca63c00 Mon Sep 17 00:00:00 2001 From: Jigar wala Date: Tue, 12 Dec 2023 20:06:40 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=20Fix=20connection=20refused=20?= =?UTF-8?q?for=20`ipv6`=20=20(#1463)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * listen on dualstack for all gateways * disable linting for this line --- packages/core/src/network.js | 1 + packages/core/src/server.js | 10 +++++----- packages/core/test/unit/server.test.js | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/core/src/network.js b/packages/core/src/network.js index cff14b163..5a420d779 100644 --- a/packages/core/src/network.js +++ b/packages/core/src/network.js @@ -171,6 +171,7 @@ export class Network { this.#pending.delete(requestId); // guard against redirects with the same requestId + // eslint-disable-next-line babel/no-unused-expressions pending?.request.url === event.request.url && pending.request.method === event.request.method && await this._handleRequest(session, { ...pending, resourceType, interceptId }); diff --git a/packages/core/src/server.js b/packages/core/src/server.js index c51c56240..a574352ad 100644 --- a/packages/core/src/server.js +++ b/packages/core/src/server.js @@ -114,9 +114,9 @@ export class Server extends http.Server { }); } - // return host bind address - defaults to 0.0.0.0 + // return host bind address - defaults to "::" get host() { - return process.env.PERCY_SERVER_HOST || '0.0.0.0'; + return process.env.PERCY_SERVER_HOST || '::'; } // return the listening port or any default port @@ -127,11 +127,11 @@ export class Server extends http.Server { // return a string representation of the server address address() { let port = this.port; - // we need to specifically map 0.0.0.0 to localhost on windows as even though we - // can listen to all interfaces using 0.0.0.0 we cant make a request on 0.0.0.0 as + // we need to specifically map "::" to localhost on windows as even though we + // can listen to all interfaces using "::" we cant make a request on "::" as // its an invalid ip address as per spec, but unix systems allow request to it and // falls back to localhost - let host = `http://${this.host === '0.0.0.0' ? 'localhost' : this.host}`; + let host = `http://${this.host === '::' ? 'localhost' : this.host}`; return port ? `${host}:${port}` : host; } diff --git a/packages/core/test/unit/server.test.js b/packages/core/test/unit/server.test.js index 39ed95621..895eeeeab 100644 --- a/packages/core/test/unit/server.test.js +++ b/packages/core/test/unit/server.test.js @@ -22,7 +22,7 @@ describe('Unit / Server', () => { describe('#host', () => { it('returns the host', async () => { - expect(server.host).toEqual('0.0.0.0'); + expect(server.host).toEqual('::'); }); describe('with PERCY_SERVER_HOST set', () => {