Repository navigation
test(linear): read retry traces only after every span is on disk - #35386
Conversation
[Low impact] This test-only change appears safe to merge. SummaryThis test-only change delays background trace writes so
Reviews (1) · Last reviewed commit: "test(linear): read traces only after eve..." · Reviewed by Greptile |
|
STATUS: ready. Head ef27d09. CI-flake fix from the unit-shard triage; load rule run locally (pnpm tc, typecheck:ci, code-quality, anti-slop, oxlint, ast-grep scan and gates) plus the affected tests. Review requested from e9-reviewer. Not merged. |
|
No actionable comments were generated in the recent review.
|
ELI5
A Linear retry test checks the trace file for one record per attempt. Trace writes are batched and written in the background. On a slow CI disk the test sometimes read the file while a background batch was still being written, saw one record instead of two, and failed. The test now turns background writing off, so every record is on disk when it reads.
What Changed
Before:
linear-request-recovery.test.ts› "admits transient SDK raw aggregates only within the distinct-node budget" failed at random:expected [ … ] to have a length of 2 but got 1(#35330, job 123097375526).After: the test's trace sink never starts a background batch, so
records()(sink.flush()→flushSync, then read) always sees every span, in order.Mechanism:
flushSyncappends whatever is still queued, but does not wait for a batch already being written.records()read the file.batchWindowMsset to the longest timer Node accepts, so onlyflushSyncever writes.Why
The race is in what the test reads, not in the product: background batching is right for the app, where nothing reads the trace mid-write.
Reproduced deterministically: with a 400 ms delay added inside the writer's background append, three tests in this file fail ("admits transient…", "recovers generated and raw SDK reads…", "stops persistent real resets…"). With this change all 23 pass under that same delay. The delay was local only and is not committed.
Alternatives considered: making
records()async and awaitingflushAsync()also works, but it rewrites about 15 call sites for the same result.Flag-off: test-only.
User-risk: none.
Linked Issue
CI flake triage (unit shards blocking merges).
Visual Proof
N/A. Test-only.
Testing
The file passes 3 runs in a row normally and 3 runs under the simulated slow disk. Without the change, it fails under the slow disk.
Checks run:
pnpm tc,pnpm run typecheck:ci,pnpm run check:code-quality:changed, anti-slop oxlint, oxlint, ast-grep scan, the flaky-test filter and gates.Review
Agent skill upstream boundary
Notes
The test still runs on the Node runtime, as listed in
vitest-node-runtime-files.mjs.Status
Ready for review.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)