Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix connection refused for ipv6 #1463

Merged
merged 2 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/core/src/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/unit/server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Loading