Repository navigation
test(plugin-hono-server): wait for the response head instead of a fixed sleep in adapter-drain - #35638
Merged
objectstack-fleet[bot] merged 1 commit intoNov 19, 2026
Conversation
…ed sleep in adapter-drain The idle keep-alive case read the socket 50 ms after writing its request; on a loaded runner the response had not arrived and the connection header read as undefined. A bounded wait on the socket (5 s deadline, clear failure message) replaces the sleep there and in two other cases whose sleep stood in for waiting for bytes they assert on. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgTyMahdAdhXSzgy2nt
Contributor
📓 Docs Drift CheckNothing in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 0 changed package(s)), so this run has no opinion about the docs. What this run could not see
Coarse fallback — 0 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): |
Contributor
Author
|
repo:objectstack#1 · os-sales · session_01L6bhgTyMahdAdhXSzgy2nt Landing · 2026-11-19T20:36Z · area b1-B self-review ACCEPT on head Self-review (l1-review-checklist):
State: ready + auto-merge now; #35621 closes on merge. |
objectstack-fleet
Bot
deleted the
claude/issue-35621-adapter-drain-keepalive-wait
branch
November 19, 2026 21:02
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.
Fixes #35621
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
packages/plugins/plugin-hono-server/src/adapter-drain.test.tsonly (test-only).waitForResponseHead(conn, timeoutMs = 5000)next torawConnection/splitResponse: resolves once the connection has received a response head (through the blank line after the headers); rejects with a message naming the bytes received if the deadline passes or the connection closes first.sleep(50)before reading the response is replaced byawait waitForResponseHead(idle). The assertion is unchanged.sleep(100)stays (it also gives the big response time to callend()and fill the socket buffers, which the next two assertions read), and the wait for the idle connection's head is added after it.sleep(100)replaced by the wait before asserting on the head.No retry, no longer sleep. No changeset: the package builds from
src/index.ts; afterpnpm --filter @objectstack/plugin-hono-server build,waitForResponseHeadhas 0 hits indist/while the controlinFlightResponseshas 4, so nothing published changes (skip-changeset).Tests
Read first: the helper
waitForResponseHead(listener order:rawConnection's collector is registered first, soreceived()already holds the chunk when the helper checks it), then the idle keep-alive case.Two-minute check:
pnpm --filter @objectstack/plugin-hono-server exec vitest run --maxWorkers=2 src/adapter-drain.test.tsshould printTests 12 passed (12).File run and typecheck at 7db8fd8
Loop under CPU pressure: new 50/50 green; old version reproduced 1 in 20
Pressure: 12 parallel busy loops (
sh -c 'while :; do :; done', 3x the 4 CPUs of this container), started before the loop and killed by a trap at the end. Each run is a freshpnpm exec vitest run --maxWorkers=1 src/adapter-drain.test.ts(whole file, 12 cases). The old version is theorigin/mainfile copied in under another name for the run and removed afterwards.RESULT new: 50 passed, 0 failed of 50(12 busy loops only; load average about 14.6).RESULT old: 19 passed, 1 failed of 20. The failure is the reported one:FAIL ... an idle keep-alive connection is released at drain start/AssertionError: expected undefined to be 'keep-alive'. Honest caveat: that loop ran under the same 12 busy loops PLUS this branch's derived gate scripts running at the same time for its first part, and the one failure (run 3) fell inside that window; the new-version loop did not have the gate scripts on top. One earlier old-version run under the 12 busy loops alone passed (a script bug invalidated the rest of that first old loop, so it is not counted).Acceptance notes
Verification
Derived gates (dispatch-gates --commands, 52 families) at 7db8fd8
pnpm check:dual-build-cjs-loadsexit 3,pnpm check:lean-entry-closureexit 3: NOT MEASURED locally (both need the whole workspace'sdist/; neither reads this test file's behaviour). CI runs them.dispatch-gates --ran: 52 derived, 50 run, 2 NOT-MEASURED (from a recorded exit 3), 0 UNRUN.node scripts/check-nul-bytes.mjsexit 0.Ablation: not done; the diff changes test timing, not a behaviour a test pins. The old-version loop above is the before/after reading.
🤖 Generated with Claude Code
https://claude.ai/code/session_01L6bhgTyMahdAdhXSzgy2nt