Skip to content

Commit 7274a5f

Browse files
apply code reviews
1 parent 4b1dc32 commit 7274a5f

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/lib/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ export default {
4646
EDGE: 'edge',
4747
EDGE_CHANNEL: 'msedge',
4848
WEBKIT: 'webkit',
49+
MIN_PORT_RANGE: 49100,
50+
MAX_PORT_RANGE: 60000,
4951

5052
// discovery browser launch arguments
5153
LAUNCH_ARGS: [

src/lib/server.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@ import { Context } from '../types.js'
66
import { Logger } from 'winston'
77
import { validateSnapshot } from './schemaValidation.js'
88
import { pingIntervalId, startPollingForTunnel, stopTunnelHelper, isTunnelPolling } from './utils.js';
9+
import constants from './constants.js';
910
var fp = require("find-free-port")
1011

1112
const uploadDomToS3ViaEnv = process.env.USE_LAMBDA_INTERNAL || false;
1213

1314
// Helper function to find an available port
1415
async function findAvailablePort(server: FastifyInstance, startPort: number, log: Logger): Promise<number> {
1516
let currentPort = startPort;
16-
let attempts = 0;
17-
let maxAttempts = 10;
1817

1918
// If the default port gives error, use find-free-port with range 49100-60000
2019
try {
@@ -25,7 +24,7 @@ async function findAvailablePort(server: FastifyInstance, startPort: number, log
2524
log.debug(`Port ${currentPort} is in use, finding available port in range 49100-60000`);
2625

2726
// Use find-free-port to get an available port in the specified range
28-
const availablePorts = await fp(49100, 60000);
27+
const availablePorts = await fp(constants.MIN_PORT_RANGE, constants.MAX_PORT_RANGE);
2928
if (availablePorts.length > 0) {
3029
const freePort = availablePorts[0];
3130
await server.listen({ port: freePort });

0 commit comments

Comments
 (0)