Repository navigation
Fix flaky partial merge shutdown test: wait for its own request - #63
Merged
Merged
Conversation
requestAdmitted() resolved on the server's first 'request' event from any client. When another client reached the port first (a polling tab or a reused ephemeral port), the test started shutdown before the server had accepted its own partial merge request. The listener then closed with that connection still queued, so the client saw "connect ECONNRESET", and afterEach reported "Server is not running." The helper now tags each partial request with a unique header and resolves only when that request's headers are parsed. The merge test sends a foreign request first as a deterministic regression: it fails with the old helper and passes with the new one. The 503 and zero-merge assertions are unchanged; disabling the server's shutdown merge guard still fails the test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved review issues remain.
Review effort: Lite
Findings: None
What changed in this PR
Fixes flaky shutdown tests by ensuring they wait for admission of their own marked request.
Changes:
- Adds unique request markers to
requestAdmitted(). - Applies markers to partial-request shutdown tests.
- Adds a competing request regression scenario.
| File | Description |
|---|---|
test/browser/review.spec.ts |
Makes shutdown request-admission tests deterministic. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
blocks a partially received merge request when shutdown startsfailed about 1 in 5 runs onmain. The errors wereconnect ECONNRESET 127.0.0.1:<port>, thenServer is not running.Cause
The test was wrong; the server is correct.
requestAdmitted()resolved on the server's first'request'event from any client. When another client reached the port first, the test calledclose()before the server had accepted its own partial merge request. Examples of another client: a polling tab, or a pooled connection to a reused ephemeral port.connect ECONNRESET(theconnectsyscall shows that the server never accepted the connection).Server is not runningis a side effect. The test threw before its last line restarts the server, soafterEachclosed an already-closed server.close()inweb/server.tsworks as designed: it blocks new work, bounds the drain, and aborts active requests.Fix
This PR changes only
test/browser/review.spec.ts.requestAdmitted()now returns a uniquex-codeboost-test-requestheader. It resolves only when the server parses the headers of the request that carries that header. The three partial-request shutdown tests use it.GET /api/settings).Evidence
Results on head
a2328a0:connect ECONNREFUSED(orECONNRESET), thenServer is not runningweb/server.ts:58--repeat-each 20npm run typechecktest/agent-supervisor.test.ts: Docker container tests that time out at 60 s on the local host. Vitest includes onlytest/*.test.ts, so it does not load the changed file.I could not reproduce the original flake naturally. It did not occur in 40 Playwright runs under CPU load or in 320 standalone harness runs. The deterministic regression reproduces the same failure signature.
Review-lesson audit
Covered by the existing rule in AGENTS.md "Required race regressions": A request is partially received, then shutdown starts, then the request completes. This PR adds no new rule.
Review rounds
a2328a0): no findings; Copilot recommended approval. Nothing changed and nothing was declined.🤖 Generated with Claude Code