Skip to content

Commit d6ddd28

Browse files
authored
fix: Use local port to avoid triggering the firewall (#1833)
When `web-ext run` starts, the following prompt shows briefly on macOS: > Do you want the application "node" to > accept incoming network connections? This is because we use `listen(0)` to find a port, and by default, this method listens on any network interface. Since we are only looking for free ports and not network connections, limit `listen()` to localhost only.
1 parent 4c612ee commit d6ddd28

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

src/firefox/remote.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,8 @@ export async function connectWithMaxRetries(
251251
export function findFreeTcpPort(): Promise<number> {
252252
return new Promise((resolve) => {
253253
const srv = net.createServer();
254-
// $FLOW_FIXME: flow has his own opinions on this method signature.
255-
srv.listen(0, () => {
254+
// $FLOW_FIXME: signature for listen() is missing - see https://github.com/facebook/flow/pull/8290
255+
srv.listen(0, '127.0.0.1', () => {
256256
const freeTcpPort = srv.address().port;
257257
srv.close(() => resolve(freeTcpPort));
258258
});

tests/functional/fake-amo-server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ http.createServer(function(req, res) {
5151
} else {
5252
process.exit(1);
5353
}
54-
}).listen(8989, () => {
54+
}).listen(8989, '127.0.0.1', () => {
5555
process.stdout.write('listening');
5656
process.stdout.uncork();
5757
});

tests/functional/fake-firefox-binary.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,4 @@ net.createServer(function(socket) {
5555
});
5656

5757
socket.write(toRDP(REPLY_INITIAL));
58-
}).listen(getPortFromArgs());
58+
}).listen(getPortFromArgs(), '127.0.0.1');

tests/unit/test-firefox/test.remote.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,8 @@ describe('firefox.remote', () => {
390390
async function promiseServerOnPort(port): Promise<net.Server> {
391391
return new Promise((resolve) => {
392392
const srv = net.createServer();
393-
srv.listen(port, () => {
393+
// $FLOW_FIXME: signature for listen() is missing - see https://github.com/facebook/flow/pull/8290
394+
srv.listen(port, '127.0.0.1', () => {
394395
resolve(srv);
395396
});
396397
});

0 commit comments

Comments
 (0)