Skip to content

[finding][cli] login-json-ndjson.e2e.test.ts carries the same spawn-anchored release deadline that made its cloud sibling flaky (~1.4x margin measured) #6872

Description

@os-project-manager

Observation-class finding, split out of #6855 rather than fixed there, because it is a different file covering a different command (#6531 os login, not #6730 os cloud login) and I could not reproduce a failure in it. Filed unassigned with no priority: label; recording measurements so whoever picks it up does not re-collect them.

The structural defect

packages/cli/test/login-json-ndjson.e2e.test.ts is the harness #6838 copied to build the cloud sibling, and it has the identical anchoring bug that #6855 was filed for:

  • const deadline = setTimeout(..., RELEASE_DEADLINE_MS) at :205
  • execFile('script', ...) at :219

So the 20 s escape-hatch budget is armed before the child is spawned and therefore charges script(1) startup, the tsx transform of the oclif command tree, and module loading against a budget that exists to police the emission contract. The assertion it protects is at :292, with the same wording the cloud file had:

expect(ok.releasedByDeadline, 'the device record never reached stdout early').toBe(false);

That message is a false diagnosis under startup latency: the record does reach stdout early, the budget simply expired while the child was still booting.

Why this is a finding and not a defect report

I load-tested it exactly as I load-tested the cloud file — 8 concurrent vitest processes, 4-core box:

file concurrent x8 result
cloud-login-json-ndjson.e2e.test.ts (unfixed) 2 failed / 8
login-json-ndjson.e2e.test.ts 0 failed / 8

It did not cross the threshold. The margin, however, is thin — and that is the actionable part:

file child runs per file wall clock under x8 load approx per child
sibling (os login) 2 28.2–30.0 s ~14.5 s
cloud (os cloud login) 3 44.7–49.6 s ~16 s

Against a 20 s budget that includes startup, ~14.5 s per child is roughly 1.4x headroom. The cloud file crossed; this one sits just underneath. A busier runner tips it, and then it ejects a PR with a different line number, and the next lane pays the #6855 diagnosis cost from scratch.

The fix, if triage wants it

Mechanically identical to the one in the #6855 PR, and test-only:

  1. Have the fake endpoint resolve a deviceCodeIssued promise (declared Promise< void >) when it serves /api/v1/auth/device/code.
  2. Arm the deadline from that promise instead of before execFile, holding the handle in a ReturnType< typeof setTimeout > that may be undefined.
  3. Leave RELEASE_DEADLINE_MS at 20 s — the point is re-anchoring what the budget measures, not widening it.

Measured on the cloud file, that moves the guarded window from ~3 500 ms of startup to the ~20 ms the contract actually governs, and the #6531 ordering assertion still goes red when the buffered-emit defect is restored (verified by reverting the early-emit limb).

Not in scope

Provenance

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions