fix(tstest): Improve free port selection for Chrome runner and bump smartnetwork dependency
This commit is contained in:
		| @@ -3,6 +3,6 @@ | ||||
|  */ | ||||
| export const commitinfo = { | ||||
|   name: '@git.zone/tstest', | ||||
|   version: '2.3.7', | ||||
|   version: '2.3.8', | ||||
|   description: 'a test utility to run tests that match test/**/*.ts' | ||||
| } | ||||
|   | ||||
| @@ -319,20 +319,19 @@ import '${absoluteTestFile.replace(/\\/g, '/')}'; | ||||
|   private async findFreePorts(): Promise<{ httpPort: number; wsPort: number }> { | ||||
|     const smartnetwork = new plugins.smartnetwork.SmartNetwork(); | ||||
|      | ||||
|     // Find HTTP port in range 30000-40000 | ||||
|     const httpPort = await smartnetwork.findFreePort(30000, 40000); | ||||
|     // Find random free HTTP port in range 30000-40000 to minimize collision chance | ||||
|     const httpPort = await smartnetwork.findFreePort(30000, 40000, { randomize: true }); | ||||
|     if (!httpPort) { | ||||
|       throw new Error('Could not find a free HTTP port in range 30000-40000'); | ||||
|     } | ||||
|      | ||||
|     // Find WebSocket port in range 30000-40000 (different from HTTP port) | ||||
|     let wsPort = await smartnetwork.findFreePort(httpPort + 1, 40000); | ||||
|     // Find random free WebSocket port, excluding the HTTP port to ensure they're different | ||||
|     const wsPort = await smartnetwork.findFreePort(30000, 40000, {  | ||||
|       randomize: true, | ||||
|       exclude: [httpPort] | ||||
|     }); | ||||
|     if (!wsPort) { | ||||
|       // Try again from the beginning of the range if we couldn't find one after httpPort | ||||
|       wsPort = await smartnetwork.findFreePort(30000, httpPort - 1); | ||||
|       if (!wsPort) { | ||||
|         throw new Error('Could not find a free WebSocket port in range 30000-40000'); | ||||
|       } | ||||
|       throw new Error('Could not find a free WebSocket port in range 30000-40000'); | ||||
|     } | ||||
|      | ||||
|     // Log selected ports for debugging | ||||
|   | ||||
		Reference in New Issue
	
	Block a user