Skip to content

test(link): hold the large Child write so the relay overload case holds on Windows - #8670

Merged
lidge-jun merged 4 commits into
devfrom
fix/dev-red2-link-windows-b
Nov 13, 2026
Merged

lidge-jun merged 4 commits into
devfrom
fix/dev-red2-link-windows-b

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

windows 12/14 of dev batch run 43369456647 timed out at 60 s in tests/clients/link-ws-relay.test.ts:228, "link WebSocket on the Child: an advertising Home > a second Codex message while the first is still unflushed toward the Home closes both legs (1013, 1001)". The case came from #8619 (09f9d43644). It made the first 8 MiB message "unflushed" by pausing the Home's socket. Windows can accept a large send into its socket buffer at once, the same cause #8627 fixed for the link traffic tests, so the write completed and the overload never triggered.

The test now holds completion of large node:net writes with the shared tests/helpers/held-socket-writes.ts helper from #8627, which gains an idempotent releaseHeldSocketWrites(). Write errors and socket end/close settle a held write at once, and each callback settles once. Each hold owns its release state, so restoreSocketWrites() releases what that hold still holds, and a completion arriving after the restore is never kept by a later hold. A native success after a close-settled write is ignored. tests/clients/held-socket-writes.test.ts covers these orderings deterministically with a controllable base write, and reverting either fix fails its case. The case releases after the 1013 close is observed. It asserts the same close codes (1013 to Codex, 1001 to the Home) and that exactly the first message's length reached the Home. Open #8658 edits this file but does not touch this case. Test-only.

Verification

  • Windows simulated on Linux with writes completing at once: on dev the case times out; with this change it passes.
  • bun test tests/clients/link-ws-relay.test.ts tests/clients/link-traffic.test.ts tests/clients/link-request-zstd.test.ts (all helper users): 64 pass, 0 fail, both normally and under the eager-write preload. bun run typecheck: exit 0.
  • NOT RUN: a native Windows runner (next dev batch), and the full suite.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Summary by CodeRabbit

  • Tests
    • Expanded coverage for stalled socket writes, including release behavior and handling of errors or socket closures.
    • Added checks that queued messages and close notifications are processed in the expected order under backpressure.
    • Improved test cleanup to restore socket behavior after each test.

@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner November 13, 2026 07:36
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T07:37:45.623948Z 7fbff0d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the chore Maintenance, CI, tests, refactors, or build changes (not a user-facing bug or feature). label Nov 13, 2026
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The socket-write test helper now supports cycle-based holding and release of large-write completions. New tests cover completion, error, and socket-closure behavior. The relay overload test uses the helper to verify close codes and forwarded messages.

Changes: Held socket-write lifecycle

Layer / File(s) Summary
Hold and release socket-write completions
tests/helpers/held-socket-writes.ts, tests/clients/held-socket-writes.test.ts, scripts/test-layout/layout-clients.json, tests/fixtures/test-layout-expected.json
The helper tracks held completions by cycle, releases them once, and settles writes immediately on errors or socket closure. New tests cover these cases and completions spanning restore boundaries. The test-layout mappings include the new test.
Verify relay overload behavior
tests/clients/link-ws-relay.test.ts
The test holds completions for writes of at least 1 MiB. It checks that Codex closes with 1013, then releases the held write and checks that Home closes with 1001 after only the first message is forwarded. It restores the original socket-write behavior in finally.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Possibly related PRs

  • lidge-jun/opencodex#8627: Adds the held-write helper used by link tests. This change updates that helper’s release behavior and uses it in the relay overload test.
Merge Risk: Minimal · up to f35f7

This change only adjusts test infrastructure to make a Windows relay test deterministic. It does not alter production behavior, and no actionable merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: the relay overload test now holds the large Child write so the case holds on Windows. The changeset adds a held socket-write helper, uses it in the link WebSocket rela…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: the relay overload test now holds the large Child write so the case holds on Windows. The changeset adds a held socket-write helper, uses it in the link WebSocket relay test, and adds tests for it. The title follows the test(link) convention and is specific, though it names 'Child' where the objectives describe a Home socket write, so the wording is slightly imprecise.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 331f9f4 and f35f7ca.

Files selected for processing: 1

  • tests/clients/held-socket-writes.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Review of #8670: the inline wrapper withheld write errors and left callbacks unsettled on teardown. tests/helpers/held-socket-writes.ts gains an idempotent releaseHeldSocketWrites(); errors and socket end/close already settle a held write at once, each callback settles once, and restoreSocketWrites() releases what is still held. The relay case uses the helper. Under the Windows-like eager-write preload dev's case times out and this one passes; relay, traffic and zstd files 64/0 normally and under the preload.
Second review of #8670: release state was shared across holds, so a native
completion that arrived after restore and after the next hold began was kept
until that later hold released; and a native success after a close-settled
write was added to the held set and retained.

Each hold now owns its release state, captured by its writes; restore marks
it released, so late completions settle at once. Native callbacks after a
settlement are ignored. tests/clients/held-socket-writes.test.ts drives the
helper with a controllable base write: held-until-release, error and close
settle at once, close-then-late-success keeps nothing, completion after
restore plus a new hold settles at once. Reverting either fix fails its case.
Third review of #8670: toEqual treats [] and [undefined] as equal, so a withheld success went unnoticed. Assert length and argument; reading the current hold's release state instead of the write's own now fails the late-completion case.
@lidge-jun

Copy link
Copy Markdown
Owner Author

Maintainer judgment (dev integration, MAINTAINERS.md maintainer-integration exception): merging without a second maintainer approval, as part of the DEV-RED repair for dev batch run 43369456647 (windows 12/14).

  • Exact head: f35f7cac9b559a8172af8bbf005b5ae821aaf07b. Every required PR check on this head passed, including the full Linux shards.
  • Fresh independent review on this exact head (gpt-6.1-terra, high): VERDICT: PASS, no findings, after three earlier rounds whose findings were all addressed: errors withheld by the inline wrapper, release state shared across holds, retention of a late success after close, and toEqual hiding a withheld callback. Its fresh runs: client and layout files 97 pass / 0 fail; 68 / 0 under the Windows-like eager-write preload; every helper mutation fails its case; typecheck, ratchet, structure:check and privacy:scan pass.
  • Classification: test-assumption bug from feat(link): a Child carries Codex's Responses WebSocket over its link when the Home advertises it (behind a closed Child gate) #8619 (Windows accepts the large write at once, so pausing the Home does not keep it unflushed). Test-only; the shared helper from test(link): hold large socket writes so pending-upload cases hold on Windows #8627 gains a safe release.
  • No outstanding change requests. Not yet verified on a native Windows runner; the maintainer's next dev batch covers it.

@lidge-jun
lidge-jun merged commit 49410b6 into dev Nov 13, 2026
35 checks passed
@lidge-jun
lidge-jun deleted the fix/dev-red2-link-windows-b branch November 13, 2026 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Maintenance, CI, tests, refactors, or build changes (not a user-facing bug or feature).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant