Skip to content

v0.43.0.30 fix(extract): release the --stale progress reporter when a batch fails - #62

Draft
rosseyre wants to merge 1 commit into
masterfrom
fix/progress-test-live-reporter-leak
Draft

rosseyre wants to merge 1 commit into
masterfrom
fix/progress-test-live-reporter-leak

Conversation

@rosseyre

Copy link
Copy Markdown

Summary

Fixes the intermittent test (5) failure: progress reporter > only one process-level signal handler installed across many reporters failed with Expected: 0, Received: 1 at test/progress.test.ts:229.

Root cause. The bug is in product code, not in the test. runExtract --stale (src/commands/extract.ts) lets a link/timeline flush error propagate on purpose (CDX-4), so the failed batch stays unstamped. But the error also skipped progress.finish(), which left the reporter in progress.ts's process-wide liveReporters set. The CDX-4 test in test/extract-stale.test.ts exercises exactly that path. When the two files land in the same shard and extract-stale runs first, progress.test.ts sees the leaked reporter. Whether they share a shard depends on the weight-based shard packing, which is why the failure came and went. In a long-running process (gbrain serve, the autopilot worker), the leak also means a later SIGINT/SIGTERM prints an abort for a phase that already ended.

Fix.

  • src/commands/extract.ts: the --stale sweep loop now calls progress.finish() in a finally. enrich, reindex-code and extract-conversation-facts already use this pattern. The error still propagates, and stamping behaviour is unchanged.
  • test/extract-stale.test.ts: the CDX-4 test now asserts that the live-reporter count returns to its starting value after the failed sweep.
  • Version bumped to 0.43.0.30 in VERSION, package.json and CHANGELOG.md (+ bun install).

test/progress.test.ts is unchanged. Its strict zero check is what surfaced this leak.

Test plan

  • Found the leaking file by bisecting the shard's file order: only extract-stale.test.ts + progress.test.ts together reproduce the failure
  • Without the fix, the new CDX-4 assertion fails. With the fix, extract-stale + progress pass (32/32)
  • scripts/test-shard.sh 5 10 locally: the progress test now passes, and no new failures appear. The remaining local failures are identical on unmodified master and come from this sandbox; they don't happen in CI.
  • All test/extract*.test.ts pass (253/253)
  • bun run typecheck, bun run verify (31/31), test/build-llms.test.ts
  • VERSION / package.json / CHANGELOG all show 0.43.0.30

Generated by Claude Code

… batch fails

runExtract --stale lets a flush error propagate on purpose (CDX-4) so the
batch stays unstamped, but that also skipped progress.finish(), leaving the
reporter in the process-wide live set. In a long-lived process a later signal
then emitted an abort for a phase that had already ended.

The leak also broke CI: the CDX-4 test in extract-stale.test.ts runs this
path, and progress.test.ts, sharing the same bun process in shard 5, found
one leaked live reporter instead of zero.

The sweep now finishes the reporter in a finally (the pattern enrich and
reindex-code already use), and the CDX-4 test asserts the live count is back
to where it started.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GCX2qPfuXzjf2QBmBDjbJY
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.

2 participants