diff --git a/packages/device/src/infrastructure/tunnel/tunnel.test.ts b/packages/device/src/infrastructure/tunnel/tunnel.test.ts index 32732f7e..72c9c2a7 100644 --- a/packages/device/src/infrastructure/tunnel/tunnel.test.ts +++ b/packages/device/src/infrastructure/tunnel/tunnel.test.ts @@ -383,6 +383,15 @@ describe('the TCP client', () => { }) peer.holdAcks = true const written = link.write(data) + // The first segments reach the peer after some time that depends on the machine (slow on a busy CI runner), so + // wait for them instead of a fixed pause, then let the rest of the window fill. + for ( + let waited = 0; + peer.accepted.get(ECHO_PORT) === undefined && waited < 5000; + waited += 10 + ) { + await new Promise((resolve) => setTimeout(resolve, 10)) + } await new Promise((resolve) => setTimeout(resolve, 20)) expect(peer.accepted.get(ECHO_PORT)).toBeLessThanOrEqual(8 * 1024) peer.holdAcks = false