Skip to content

test(linear): read retry traces only after every span is on disk - #35386

Merged
nwparker merged 1 commit into
mainfrom
nwparker/linear-recovery-trace-sync
Oct 28, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/linear-recovery-trace-sync

Conversation

@nwparker

@nwparker nwparker commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​7 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​6
Prod 0 0 0 0

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:

  • The local file sink queues spans and drains them in a background batch 200 ms after the first one.
  • flushSync appends whatever is still queued, but does not wait for a batch already being written.
  • The failing test fails a request, waits the 100 ms retry backoff, then succeeds. When the backoff ran past 200 ms on a busy runner, the failure span was in a batch still being written when records() read the file.
  • The test now creates its sink with batchWindowMs set to the longest timer Node accepts, so only flushSync ever 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 awaiting flushAsync() 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

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

The test still runs on the Node runtime, as listed in vitest-node-runtime-files.mjs.

Status

Ready for review.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] This test-only change appears safe to merge.

Summary

This test-only change delays background trace writes so records() can write every queued span before reading the file.

  • Linear recovery tests keep trace spans queued until they read the file.

Reviews (1) · Last reviewed commit: "test(linear): read traces only after eve..." · Reviewed by Greptile

@nwparker

Copy link
Copy Markdown
Contributor Author

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.

@coderabbitai

coderabbitai Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ff7f1143-820f-4d43-8f36-94a8b0b69807
Commits

Reviewing files that changed from the base of the PR and between c66d873 and ef27d09.

Files selected for processing: 1
  • src/main/linear/linear-request-recovery.test.ts

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

Walkthrough

The linear request recovery test adds a constant for the longest timer duration Node accepts. The test setup uses this value for the local file sink’s batchWindowMs. The test still reads the sink after flushing.

Priority: Low

Merge Risk: Minimal · up to ef27d

The test timing change is safe to merge and addresses the reported flaky-read race.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title "test(linear): read retry traces only after every span is on disk" is specific and matches the change. The PR makes the trace sink's batchWindowMs the longest timer Node accepts, so only flu…
Description check Passed The description follows the repository template. It has ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Agent skill upstream boundary, Notes, and Checklist sections. The ELI5, What Chang…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
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 "test(linear): read retry traces only after every span is on disk" is specific and matches the change. The PR makes the trace sink's batchWindowMs the longest timer Node accepts, so only flushSync writes spans and records() reads a complete file. The title names the scope (linear), the test-only nature, and the goal. It does not name the mechanism, but it is accurate.

Full details: Description check

Explanation

The description follows the repository template. It has ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Agent skill upstream boundary, Notes, and Checklist sections. The ELI5, What Changed, and Why sections are detailed and explain the race, the before and after behavior, and the alternatives considered. Gaps: the Linked Issue section says 'Fixes #' with no issue number, and only a CI flake triage note is given. The AI Disclosure section is absent. The Review section is empty. The Checklist leaves the lint, typecheck, test, and build item unchecked, although the Testing section lists other checks that ran. These gaps are non-critical, so the description is mostly complete.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files.

Finishing Touches
📝 Generate docstrings
  • 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

Comment @coderabbitai help to get the list of available commands.

@nwparker
nwparker merged commit 58d97f5 into main Oct 28, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant