Skip to content

test(live): answer the close frame so the mock server shuts down on time - #10

Merged
mrmx merged 1 commit into
mainfrom
fix/live-test-close-handshake
Oct 25, 2026
Merged

mrmx merged 1 commit into
mainfrom
fix/live-test-close-handshake

Conversation

@mrmx

@mrmx mrmx commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

What

LiveConnectionTest fails at teardown on some runs:

LiveConnectionTest.stop:119 » IO Gave up waiting for queue to shut down

It failed on the CI run of main after #8 was merged (on authenticatedSessionRefreshesJwtBeforeMintingWebSocketToken, which then also took 5 s), and once in a full local run. The tag build runs the same job, so a tag can fail this way too.

Cause

The mock WebSocket server never answered the client's close frame (WebSocketListener.onClosing was not overridden). The server side of each socket keeps its read loop alive until the client gives up, and MockWebServer.shutdown() waits only five seconds for that queue to drain.

Fix

Answer onClosing with socket.close(code, reason), completing the close handshake. Test code only.

Checked

On an 8-core machine with 16 busy loops competing for the CPU, LiveConnectionTest run 10 times in a row:

runs failing
before 6 of 10
after 0 of 10

Without the load, the test passed 15 of 15 in isolation and 8 of 8 in the full suite before the change, so it is a timing race that shows up on a busy or slow runner. The full suite passes with the change.

The mock WebSocket server never answered the client's close frame, so the server side of the socket kept its read loop alive and MockWebServer.shutdown() sometimes gave up after five seconds ('Gave up waiting for queue to shut down'), failing a LiveConnectionTest at teardown. Answering onClosing completes the close handshake.
@mrmx mrmx mentioned this pull request Oct 25, 2026
@mrmx
mrmx temporarily deployed to Preproduction October 25, 2026 14:56 — with GitHub Actions Inactive
@mrmx
mrmx marked this pull request as ready for review October 25, 2026 15:05
@mrmx
mrmx merged commit 0770735 into main Oct 25, 2026
6 checks passed
@mrmx
mrmx deleted the fix/live-test-close-handshake branch October 25, 2026 15:05

This branch was previously deployed

1 inactive deployment
Preproduction — 2b4d5074 Deployed Oct 25, 2026 by mrmx via integration #111
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant