From d4544c831da1861a03e620fa2da1a540c93e2d50 Mon Sep 17 00:00:00 2001 From: Jinwoo Hong <73622457+Jinwoo-H@users.noreply.github.com> Date: Mon, 26 Oct 2026 18:47:27 -0400 Subject: [PATCH] test(relay): wait for the relay's own close before confirming a resume (#34117) The served-relay blackbox test closed the phone and data sockets from the client and sent the resume confirm before the relay had processed the close, so on a busy runner the relay correctly answered device-resume-confirmed and the test failed (about 1.8% under load). The test now closes only the phone and waits for the relay to close the data leg with 4408, which happens in the same step that marks the connection inactive. Test-only. --- cloud/apps/relay/src/relay.blackbox.test.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/cloud/apps/relay/src/relay.blackbox.test.ts b/cloud/apps/relay/src/relay.blackbox.test.ts index 92e667a8457..a10292b3cf2 100644 --- a/cloud/apps/relay/src/relay.blackbox.test.ts +++ b/cloud/apps/relay/src/relay.blackbox.test.ts @@ -974,15 +974,12 @@ describe('served relay URL', () => { credential: resumeToken }) const originalExpiry = first.hello.resumeExpiresAt - const firstPhoneClosed = new Promise((resolveClose) => - first.phone.once('close', () => resolveClose()) - ) - const firstDataClosed = new Promise((resolveClose) => - first.data.once('close', () => resolveClose()) + // Only the relay's close of the data leg proves it saw the phone leave; a client-side close can race the confirm. + const firstDataClosed = new Promise((resolveClose) => + first.data.once('close', (code) => resolveClose(code)) ) first.phone.close() - first.data.close() - await Promise.all([firstPhoneClosed, firstDataClosed]) + expect(await firstDataClosed).toBe(4408) const closedBasis = nextMessage(host.socket) host.socket.send( JSON.stringify({