Skip to content

Commit dbeb8f8

Browse files
committed
test(devframe): use getPort for rpc-streaming tests to prevent EADDRINUSE
Fixes test flakiness and EADDRINUSE errors in CI by switching from sequential static port assignment to dynamically resolving free random ports.
1 parent db8cae4 commit dbeb8f8

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

‎packages/devframe/src/node/__tests__/rpc-streaming.test.ts‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ import { RpcFunctionsHost } from '../host-functions'
1111

1212
vi.stubGlobal('WebSocket', WebSocket)
1313

14-
let nextPort = 41000
15-
function allocatePort(): number {
16-
return nextPort++
17-
}
14+
import { getPort } from 'get-port-please'
1815

1916
interface Harness {
2017
port: number
@@ -23,7 +20,7 @@ interface Harness {
2320
}
2421

2522
async function bootHost(): Promise<Harness> {
26-
const port = allocatePort()
23+
const port = await getPort({ random: true })
2724
const mockContext = {} as DevframeNodeContext
2825
const rpcHost = new RpcFunctionsHost(mockContext)
2926

0 commit comments

Comments
 (0)