From 17bc2f02e940ad687b7699a201a0b5542361e18b Mon Sep 17 00:00:00 2001 From: JD Date: Thu, 8 Oct 2026 10:39:19 -0400 Subject: [PATCH] test(remote-wake): stop pinning the readiness budget to the millisecond ensureAwake() hands the readiness poll the caller's budget minus the wake step's own elapsed time, so on a busy runner the poll gets 39999 ms and the two tests that expected exactly REMOTE_WAKE_REQUEST_READY_TIMEOUT_MS flaked (seen in CI on #550 and in a local gate run). Both now check the value sits within a second under the budget, the shape the host-scoped wake test already uses, which still fails if the 90 s session default leaks through. --- test/remote-wake.test.ts | 7 ++++++- test/routes/session-routes.test.ts | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/test/remote-wake.test.ts b/test/remote-wake.test.ts index f1fe7f06..22b96db6 100644 --- a/test/remote-wake.test.ts +++ b/test/remote-wake.test.ts @@ -559,9 +559,14 @@ describe('RemoteWakeRegistry', () => { h.registry.ensureAwake(h.session, { force: true, timeoutMs: REMOTE_WAKE_REQUEST_READY_TIMEOUT_MS }) ).resolves.toBe(true); expect(h.waitUntilReady).toHaveBeenCalledWith(remote, { - timeoutMs: REMOTE_WAKE_REQUEST_READY_TIMEOUT_MS, + timeoutMs: expect.any(Number), signal: expect.any(AbortSignal), }); + // Not asserted to the millisecond: the wake's own elapsed time is subtracted, so a + // slow runner lands a few ms under the budget. + const [, readyOpts] = h.waitUntilReady.mock.calls[0] as [unknown, { timeoutMs: number; signal: AbortSignal }]; + expect(readyOpts.timeoutMs).toBeLessThanOrEqual(REMOTE_WAKE_REQUEST_READY_TIMEOUT_MS); + expect(readyOpts.timeoutMs).toBeGreaterThan(REMOTE_WAKE_REQUEST_READY_TIMEOUT_MS - 1_000); }); }); diff --git a/test/routes/session-routes.test.ts b/test/routes/session-routes.test.ts index 11b1e755..466ab738 100644 --- a/test/routes/session-routes.test.ts +++ b/test/routes/session-routes.test.ts @@ -2182,10 +2182,15 @@ describe('session-routes', () => { // The request budget, not the 90 s session default: the reverse proxy would // cut the request at 60 s while the session was still being built. expect(wakeWaitUntilReady).toHaveBeenCalledWith(expect.objectContaining({ hostId: 'hufflepuff' }), { - timeoutMs: REMOTE_WAKE_REQUEST_READY_TIMEOUT_MS, + timeoutMs: expect.any(Number), // The shutdown signal rides along so `WebServer.stop()` can end the poll. signal: expect.any(AbortSignal), }); + // Not asserted to the millisecond: the wake's own elapsed time is subtracted, + // so a slow runner lands a few ms under the budget. + const [, readyOpts] = wakeWaitUntilReady.mock.calls[0] as unknown as [unknown, { timeoutMs: number }]; + expect(readyOpts.timeoutMs).toBeLessThanOrEqual(REMOTE_WAKE_REQUEST_READY_TIMEOUT_MS); + expect(readyOpts.timeoutMs).toBeGreaterThan(REMOTE_WAKE_REQUEST_READY_TIMEOUT_MS - 1_000); } finally { startShell.mockRestore(); }