Skip to content

named-gate child that exits early is misreported as EPIPE (flaky named-gate-diagnostics test) #598

Closed

Description

@khaliqgant

Summary

A named-gate child that exits early (for example wc dying before it has read all of its stdin) is misreported as could not run wc -w: EPIPE, because the spawn result's error is checked before the child's real exit status or signal. In CI this makes tests/named-gate-diagnostics.test.ts fail intermittently, and in production a real failing child would be reported as an EPIPE rather than what it actually did.

Where

  • Spawn: packages/sdk/src/named-gate-lowering.ts:128; the result.error check is at :131. Identical at ae49491b, 2e8b9977 and 30b0565c.
  • Test: packages/sdk/tests/named-gate-diagnostics.test.ts:245-282, describe "word_count_bounds reports why its own child failed". The fake wc exits without reading stdin.

Evidence

A read-only diagnostic on 2026-10-02 ran only that test file 20 times per checkout:

Checkout Condition Runs Fails
main ae49491b idle 20 0
PR #501 head 2e8b9977 idle 20 0
main ae49491b loaded (24 busy loops + 4 parallel copies) 20 4
PR #501 head 2e8b9977 loaded 20 3

Different tests fail on different runs ("reports output that is not a count", "reports a nonzero exit with what wc said", "reports a signal rather than an empty exit 1"), always with EPIPE. The same file failed twice on CI for PR #501 (run 36986633196, attempts 1 and 2) even though #501 does not touch these files. The wc code and its test are byte-identical between main and the PR head.

Not verified: the CI runner's real load (the loaded runs only approximate it), why the older PR head 93ce64a3 passed, and the full suite. Only this one file was run.

Suggested fix

  1. Check result.signal and result.status before result.error, or treat result.error as fatal only when both status and signal are null (the child never ran).
  2. Add a regression test where the fake wc exits without reading stdin and the input is large (about 1 MB), which forces the EPIPE every time; assert the output contains "exited 2".
  3. Do not fix this only by making the test fakes read stdin first (cat >/dev/null). That turns the test green but leaves the misreporting in place.

Filed by Chief on Khaliq's instruction (2026-10-02).

Activity

  1. khaliqgant commented on Oct 10, 2026

    @khaliqgant
    MemberAuthor

    Fixed on main by #612 (merged 2026-10-04). The lowering checks the child status and signal before treating a non-EPIPE spawn error as "could not run", and packages/sdk/tests/named-gate-diagnostics.test.ts covers a stub wc that exits before reading stdin. #603 was the same fix and is now conflicting with that landing, so I closed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions