Skip to content

🤖 tests: agentSession.preparationRetention GC check flakes in the shared unit shard #7061

Description

@ThomasK33

src/node/services/agentSession.preparationRetention.test.ts:41 failed in the merge queue on a tree that passed in PR CI. The test came from #7025.

What failed: Test / Unit (6/6) in merge-group run for #7031 (merge commit c3e2549d74): AgentSession preparation retention > a started stream's request closures do not keep the pre-stream failure callback alive got Expected: true, Received: false from expect(await collected(callbackScopeRef)).toBe(true).

Why it looks like a flake:

  1. The merge-group tree (eda2412777) is identical to the tree that passed Test / Unit (6/6) in 🤖 tests: e2e guards for the turn-end TODO nudge's tools #7031's own PR run 39387467456.
  2. On that tree, the file passed 15 of 15 runs alone and 8 of 8 runs with --coverage.
  3. The test asserts that Bun.gc(true) collects a WeakRef target. In the shared shard process, other suites' state or conservative stack scanning can keep the object alive.

I did not reproduce the failure, so the exact retainer is unknown.

Possible fixes: run the file in its own process (isolated_unit_tests in scripts/test-unit-ci.sh), or retry the collection check a few rounds before failing.


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high • Cost: $36.60

Activity

  1. self-assigned this
    on Oct 20, 2026
  2. ThomasK33 commented on Oct 20, 2026

    @ThomasK33
    MemberAuthor

    Seen again on PR #7050 (head 6d43f5c, a UI-only diff), Test / Unit (1/6), run 39390942010 job 118522091854: (fail) AgentSession preparation retention > a started stream's request closures do not keep the pre-stream failure callback alive [970.36ms]. I re-ran the failed job.


    Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

  3. ThomasK33 commented on Oct 20, 2026

    @ThomasK33
    MemberAuthor

    Desk clearance: no desk lane owns #7061. The perf owner's lane 1 (ws 348be810de) may open the fix: add the preparationRetention test file to isolated_unit_tests in scripts/test-unit-ci.sh, the same pattern as #7046 (about 3 lines, no test logic change). CLEAR: no open desk PR touches scripts/test-unit-ci.sh. Keep #7061 open with its trigger if the isolation hides a real leak, rather than closing it as fixed.


    Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

  4. ThomasK33 commented on Oct 20, 2026

    @ThomasK33
    MemberAuthor

    Reopening (perf owner): the flaky check came back after #7062. PR #7073 (base 7c86eac6c1, which contains #7062 aa6d658340; the diff touches only src/node/services/mock/mockAiStreamPlayer*) failed Test / Unit (1/6) in run 39408886425:

    (fail) AgentSession preparation retention > a started stream's request closures do not keep the pre-stream failure callback alive [950.00ms]

    So moving the callback out of the async test frame was not enough in the shared shard process. The isolation fix (the closed #7063: run the file in its own process, 7 lines in scripts/test-unit-ci.sh) is still an option.


    Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high • Cost: $1569.15

  5. added 2 commits that reference this issue on Oct 20, 2026
    aa6d658
    1516098
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions