codex-security icon indicating copy to clipboard operation
codex-security copied to clipboard

Flaky: auth.test.ts "releases native login pipes when the cross-platform fallback fires"

Open rohanpoudel2 opened this issue 3 months ago • 3 comments

Summary

tests-ts/auth.test.ts — "releases native login pipes when the cross-platform fallback fires" failed once during a full-suite run and passed on every rerun afterwards, both in isolation and in the full suite. Filing it because an intermittent failure in the suite is worth a look before it lands in CI, not because I can reproduce it on demand.

Environment

  • @openai/codex-security 0.1.5, on a branch based on main at ea19f24
  • macOS 15 (Darwin 25.5.0), Bun 1.3.14, Node.js 24.11.1
  • bun test --timeout 30000 ./tests-ts

Observed

One failure in one full-suite run. Immediately rerunning the file alone passed, and three subsequent full-suite runs passed. I did not capture the assertion output before the rerun overwrote it, which is a gap in this report.

Why it is plausibly real rather than machine noise

The test name describes releasing OS pipes when a fallback path fires, which is the shape of thing that tends to be sensitive to process/descriptor timing rather than to logic. Bun runs test files in one process, so descriptor pressure or ordering from a neighbouring file is a candidate. Two suite features make that worth checking specifically:

  • other tests manipulate process.umask and restore it in finally, so they share mutable process state
  • other tests spawn subprocesses and pack tarballs, so descriptor counts vary between runs

Suggested direction

Run the file under repetition and under load to see whether it is order-dependent or descriptor-dependent, e.g. a loop of full-suite runs, and separately the file alone with an artificially lowered descriptor limit. If it is a genuine race in the fallback's cleanup, the fix belongs in the code under test rather than the assertion. If it turns out to be a test-only ordering assumption, an explicit wait on the release rather than a timing-dependent assertion would settle it.

Happy to dig into it if a maintainer confirms it is worth chasing — I did not want to change a passing test on the strength of a single unreproduced failure.

rohanpoudel2 avatar Aug 04 '26 00:08 rohanpoudel2

Ran the repetition experiment you suggested, on a different OS/runtime. No reproduction, but with a caveat that weakens the result — flagging both.

What I ran

Windows 11, bun 1.3.13, main @ ea19f24, deps via bun install:

Run Result
auth.test.ts alone 16 pass, 1 skip, 0 fail
-t 'releases native login pipes', 20 repetitions 0/20 failures
Full ./tests-ts, 3 runs the named test passed in all 3

The caveat

My full-suite runs are not a clean baseline: 77 tests failed deterministically — the same 77, identically, in all three runs (656 pass / 77 fail each time). They look environmental rather than new:

  • symlink tests (rejects a repository-controlled output symlink…, …npm-style bin when Node preserves main symlinks) — Windows symlink creation needs privilege
  • the GitHub release workflow safeguards block — consistent with #206's bash-resolution problem; I have WSL present but with no distro installed
  • Node 20.18.1 locally vs engines: ^22.13.0 || ^24 || ^26

Since Bun runs test files in one process, those failures alter exactly the descriptor pressure and ordering that your hypothesis points at. So "did not reproduce here" is weak evidence — a clean suite on macOS/Linux is where a repetition loop would actually be informative.

What would settle it

The cheapest decisive run is in your own CI: the same file under -t in a loop, plus one full-suite loop, on a runner where the suite is otherwise green. If it never fires there either, the single observed failure was probably descriptor pressure from a neighbouring file rather than a race in the fallback's cleanup.

I did not touch the test — agreed with your instinct not to change a passing assertion on one unreproduced failure.

Souptik96 avatar Aug 04 '26 07:08 Souptik96

Thanks — and thanks especially for flagging the caveat rather than just reporting the green result. You were right that it was the weak part: 77 deterministic failures in-process is exactly the descriptor pressure the hypothesis blames, so a pass under those conditions proves little either way.

I ran the decisive version you asked for, on the clean baseline you didn't have.

Baseline

macOS 15 (Darwin 25.5.0), bun 1.3.14, Node 24.11.1, upstream/main @ 18a183f (0.1.6):

907 pass | 11 skip | 0 fail | 918 tests across 36 files | 48.13s

Zero failures, so the descriptor and ordering conditions are the intended ones rather than the wreckage of 77 unrelated failures.

18a183f is later than the ea19f24 in my original report, but tests-ts/auth.test.ts is byte-identical across the two (md5 886c9dd7…c6a6) and src/auth.ts has no commits between them, so this is the same code path I filed against.

Results — 82 runs, 0 failures

Phase Runs Result
Full suite (bun test ./tests-ts) 12 907 pass / 0 fail every run; the named test never failed
auth.test.ts alone 30 0 failures
-t 'releases native login pipes' 40 0 failures

Phase 1 is the one that matters, since it reproduces the in-process neighbour pressure with the suite otherwise green.

Read

Your explanation looks right. 12 clean full-suite runs on a green baseline is decent evidence there is no race in the fallback's pipe cleanup, and that the single failure I saw came from descriptor pressure produced by a neighbouring file rather than by this test. Worth stating the ceiling on that, though: by the rule of three, 0 failures in 12 full-suite runs only bounds the per-run rate at about 25% with 95% confidence. That rules out a frequent flake, not a rare one — the 82-run total reads stronger than the evidence actually is, since phases 2 and 3 don't carry the neighbour pressure.

Happy for this to be closed as unreproducible. If it ever fires again I'll capture the full-suite output and the failing assertion rather than reopening on the same single data point. Agreed throughout on not touching a passing assertion over one unreproduced failure.

rohanpoudel2 avatar Aug 05 '26 17:08 rohanpoudel2

Thanks for running the clean-baseline version - agreed on closing.

Souptik96 avatar Aug 06 '26 03:08 Souptik96