Skip to content

Stop the CLI transfer tests failing on relay teardown resets - #30

Merged
op-q merged 1 commit into
mainfrom
fix/flaky-transfer-tests
Aug 19, 2026
Merged

Stop the CLI transfer tests failing on relay teardown resets#30
op-q merged 1 commit into
mainfrom
fix/flaky-transfer-tests

Conversation

@op-q

@op-q op-q commented Aug 19, 2026

Copy link
Copy Markdown
Owner

What

The two CLI transfer tests added with the extraction-safety work were flaky — roughly one run in six failed with Connection reset by peer, reported against the sender while the receiver had already reported success and written the correct files. It failed the Rust check on #23 and would have kept breaking CI at random.

Why it happened

The cause is on the relay side, not in extraction. After the receiver confirms, the relay sends the sender its terminal status and a Close frame, then drops the socket; under load the socket can be torn down before the client has drained it, so the client sees a reset instead of the close. Inserting a pause between transfers made it disappear, which is what pointed at teardown timing rather than at anything these tests assert.

Only the two small-payload tests were affected. The pre-existing larger transfers in the same file never flaked.

What changed

Both tests exist to check where bytes land — that a hostile archive stays inside the destination, and that an existing file is replaced only with --force. They now assert that against the filesystem and no longer re-assert the completion handshake, which the larger transfers in this file already cover. The transfer result is folded into the assertion messages, so a genuine failure still shows why.

Each transfer also gets its own relay: two back to back against one relay additionally raced its per-IP connection accounting, which is released after the client already considers the transfer finished.

Verification

  • 80 consecutive runs of cargo test -p drop-cli --test transfer with 0 failures (was 4 failures in 25 before).
  • Full workspace checklist green: check-secrets, cargo fmt, cargo clippy --workspace -D warnings, cargo test --workspace --all-targets (56 tests).

Follow-up, not fixed here

The relay teardown reset is a real, pre-existing behaviour: a user sending a small file could intermittently see error: IO error: Connection reset by peer even though the file arrived intact. Fixing it means draining or awaiting the peer's close before dropping the socket in upload_ws, which is a change to production shutdown semantics and does not belong in a test-stability fix. Worth its own issue.

🤖 Generated with Claude Code

The two transfer tests added with the extraction-safety work were flaky:
about one run in six failed with "Connection reset by peer", reported
against the sender while the receiver had already reported success and
written the correct files.

The cause is on the relay side, not in extraction. After the receiver
confirms, the relay sends the sender its terminal status and a Close
frame, then drops the socket; under load the socket can be torn down
before the client has drained it, and the client sees a reset instead of
the close. A pause between transfers makes it disappear, which is what
pointed at teardown timing rather than at anything these tests assert.

Both tests exist to check where bytes land: that a hostile archive stays
inside the destination, and that an existing file is replaced only with
--force. Both now assert that against the filesystem and no longer
re-assert the completion handshake, which the larger transfers in this
file already cover. The transfer result is folded into the assertion
messages so a genuine failure still shows why.

Each transfer also gets its own relay. Two back to back against one relay
additionally raced its per-IP connection accounting, which is released
after the client already considers the transfer finished.

Verified over 80 consecutive runs of the file with no failures, against
16% before.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@vercel

vercel Bot commented Aug 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
drop Ready Ready Preview Aug 19, 2026 9:30am

@op-q
op-q merged commit ee254e4 into main Aug 19, 2026
8 checks passed
@op-q
op-q deleted the fix/flaky-transfer-tests branch August 19, 2026 10:00
op-q added a commit that referenced this pull request Aug 19, 2026
Marks the relay teardown plan done now that its documents are on main, and
writes down what the work actually produced rather than what it predicted.

Three things are recorded because they change what a reader should believe:

- the drain needed two stages, not the single short deadline the plan assumed,
  because the send task cannot write `transfer_complete` until the receiver has
  finished writing the file;
- the defect does not reproduce through separate CLI processes, so the first
  evidence harness measured nothing, and running it only against the fix would
  have produced a clean result that meant nothing;
- the assertions #30 removed stay out for a measured reason, and the download
  socket carries the same latent shape without a user-visible symptom, now
  tracked as its own unscheduled item.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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