Skip to content

A concurrency test asserts on wall-clock time and fails under coverage instrumentation #1320

Description

@borisno2

The flake

packages/rag/src/runtime/batch.test.tsProcessingQueueshould process items concurrently with concurrency > 1 asserts on wall-clock elapsed time:

AssertionError: expected 79 to be less than 50

It blocked a merge on PR #1318, whose diff is documentation, a changeset and package.json — no runtime source at all.

The evidence that it is a flake, and what actually causes it

In one CI run (34156198755) the identical test ran four times:

job copy result
test src pass
test dist pass
test:coverage src pass
test:coverage dist fail, 79ms vs a 50ms bound

Three passes and one failure, differing only by which copy ran and whether coverage instrumentation was on. Coverage instrumentation is the cause — it slows execution enough to breach a 50ms bound.

Two things make it worse. The suite runs twice, from src and from dist (#1311), doubling CPU contention on the runner. And a shared runner's load is not controlled at all.

Why the assertion is wrong, not just tight

The test wants to prove concurrency — that a queue with concurrency greater than one overlaps its work. Elapsed time is a proxy for that, and a proxy that a slower machine, an instrumented run, or a noisy neighbour can falsify without the behaviour changing at all.

Widening the bound would only move the threshold. Concurrency should be observed directly: record the number of in-flight tasks and assert the maximum exceeds one, or assert on the interleaving of start and finish events. That holds on any machine at any speed, and it fails when concurrency genuinely breaks — which the timing version does not reliably do in either direction.

What to do

Related

The same shape as the PGlite-absence flake fixed in #1290: a test racing a fixed budget on a shared runner. That one was given a realistic budget because its cost was genuinely bounded; this one should stop measuring time altogether, because time is not what it is testing.

Context


Generated by Claude Code

Activity

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

    ready-for-agentFully specified, ready for an AFK agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions