From 153bfa8efab7a563cf741701aa08525ecf8c8e42 Mon Sep 17 00:00:00 2001 From: Dan Motpan <24751897+SirReaDy@users.noreply.github.com> Date: Sun, 29 Nov 2026 16:08:13 +0200 Subject: [PATCH] Tunnel test: wait for the peer's first segments instead of a fixed 20 ms The window scaling test read how many bytes the fake peer had accepted after a fixed 20 ms, which was still nothing on a slow Windows runner (TypeError: actual value must be number or bigint, received undefined). --- packages/device/src/infrastructure/tunnel/tunnel.test.ts | 9 +++++++++ 1 file changed, 9 insertions(+) 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