Skip to content

test(design-tweak): order the WS relay feeders by the request bytes, not a sleep - #25544

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
fix/design-tweak-relay-flake-14146
Oct 29, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
fix/design-tweak-relay-flake-14146

Conversation

@CrysisDeu

@CrysisDeu CrysisDeu commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: test_set_cookie_stripped_from_101 stops failing on loaded CI runners with assert '101 Switching Protocols' in ''.

The test's feeder thread plays the dev server on one end of a socketpair. It sends the 101 handshake, sleeps 50 ms and closes, and never reads the relay's upgrade request. The relay writes that request first (dev_preview.py:684). On a loaded runner the relay reaches that write after the feeder has closed, gets EPIPE, returns early, and sends nothing downstream.

Why it matters

It fails PRs that never touch design-tweak (#13375 on Linux, #18150 on macOS), and each one costs a rerun.

Not a goal

  • Changing the relay itself. Returning early on a failed upstream write is correct.

Intended? / Repro

Intended? No. The 50 ms sleep is the test's only ordering, and it is not a guarantee.

Repro (read on current main 2f620d8a7c):

What changed (motivation → approach → change)

Symptom: an empty downstream read. Cause: the feeder can close before the relay writes its request. Change: order the feeder by the bytes.

  • New helper _read_relay_request(sock): reads the relay's request through \r\n\r\n with the file's existing _recv_until lost-run bound.
  • test_set_cookie_stripped_from_101: the feeder reads the request, sends the handshake, then shutdown(SHUT_WR), so the pump reads handshake-then-EOF. The test closes the feeder socket after the relay returns. The dead first feeder (up_a/up_b, never handed to the relay) is removed.
  • test_pump_sendall_oserror, test_pump_recv_oserror and test_trailing_frames_forwarded copy the same send-before-read idiom. test_trailing_frames_forwarded asserts on the downstream bytes, so it can fail the same way; it now reads the request, answers, and half-closes. The two pump-error tests asserted only errors == [], which held either way, but under the race they ended at the request write and never reached the pump they test. Their feeders now read the request first.

Backwards compatibility

Test-only. Removes nothing in src/.

Tests

The three tests above are the change. On main the first can fail under load; after this change its ordering no longer depends on scheduling.

Proof: not provable -- other: a scheduling race; this host runs no local tests, CI runs them.

Manual verification

N/A: static gates only on this host (isort, flake8). black --check already fails on this file on main in untouched lines; the new lines are black-clean.

Screenshots

Why no screenshot: No visual change: test-only.

Related Issues

Fixes #14146

Sibling sweep

Swept: grep -n "time.sleep(0.05)" test/test_design_tweak_relay_paths.py
Sibling: test/test_design_tweak_relay_paths.py test_pump_sendall_oserror -- changed here
Sibling: test/test_design_tweak_relay_paths.py test_pump_recv_oserror -- changed here
Sibling: test/test_design_tweak_relay_paths.py test_trailing_frames_forwarded (:1043) -- changed here
Sibling: test/test_design_tweak_relay_paths.py TestRelayWsPump -- not affected (already reads the request with _recv_until before answering)
Sibling: test/test_design_tweak_relay_paths.py TestRelayWsIdleCap -- not affected (its feeder never closes, so the request write cannot hit a closed peer)

Pattern harvest

Not generalizable: one test file's feeder idiom.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributed under the project's Apache-2.0 license.

@CrysisDeu
CrysisDeu requested review from a team and KiroCrewCaptain as code owners October 29, 2026 02:18
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 29, 2026
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ⏭️ skipped

Revision 4c29eb14b9cb00e2da29133ae5043cf0bc196f45 ships no reviewable capability (docs, tests or generated files only), so there is nothing to inventory. Does not block merge.

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 4c29eb14b9cb00e2da29133ae5043cf0bc196f45 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 4c29eb14b9cb00e2da29133ae5043cf0bc196f45 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Test-only change. It replaces the sleep-ordered close with a read of the relay's request followed by a half-close. That fixes the race at its root, and it takes nothing away from src/.

[DESIGN-REVIEWED] 4c29eb1

Description read

[DESCRIPTION-READ] aa12c035595e9abc8a44308c6a6433f7d8f9cebd80fe54148269199e4632cb0b

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 4c29eb14b9cb00e2da29133ae5043cf0bc196f45 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 4c29eb1

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 4c29eb14b9cb00e2da29133ae5043cf0bc196f45 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 4c29eb14b9cb00e2da29133ae5043cf0bc196f45 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 4c29eb1

Verdict parsed from the review's SHA-scoped output markers for commit 4c29eb14b9cb00e2da29133ae5043cf0bc196f45.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 4c29eb14b9cb00e2da29133ae5043cf0bc196f45 false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 29, 2026
…not a sleep

The handshake-sanitization test's feeder answered and closed its end of the
socketpair after a 50 ms sleep, without reading the relay's upgrade request.
On a loaded runner the relay wrote that request into a closed peer, returned
early, and the downstream read was empty. The feeder now reads the request
first, answers, and half-closes. The two pump-error tests get the same read so
they reach the pump they cover. The dead first feeder is removed.

Fixes #14146
@CrysisDeu
CrysisDeu force-pushed the fix/design-tweak-relay-flake-14146 branch from 98b5912 to 4c29eb1 Compare October 29, 2026 02:32
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 29, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) October 29, 2026 05:08

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tier 1 auto-approve: test (1 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: orders the design-tweak WS relay feeders by request bytes instead of a sleep.

@KiroCrewCaptain
KiroCrewCaptain merged commit 2294d11 into main Oct 29, 2026
116 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the fix/design-tweak-relay-flake-14146 branch October 29, 2026 05:08
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 29, 2026
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.

tests(design-tweak): test_set_cookie_stripped_from_101 flakes under runner load (relay pump reads '' before the fed handshake)

2 participants