Skip to content

fix(worker-pool): clear parse timeouts so --full exits promptly#146

Merged
SutuSebastian merged 5 commits into
mainfrom
fix/worker-pool-exit-delay
May 26, 2026
Merged

fix(worker-pool): clear parse timeouts so --full exits promptly#146
SutuSebastian merged 5 commits into
mainfrom
fix/worker-pool-exit-delay

Conversation

@SutuSebastian
Copy link
Copy Markdown
Contributor

Summary

  • Replace Promise.race + uncancellable delay() in createParseWorkerSession().parse() with a single setTimeout cleared on worker message, error, or dispose().
  • Orphaned 120s chunk-budget timers kept the process alive after indexing finished (~121s wall on large --full runs despite ~1s index work).
  • Add regression test: parseFilesParallel() on >12 files must return in <5s wall time.
  • Document timeout cleanup in docs/architecture.md § Worker thread parallelism.

Test plan

  • bun test src/worker-pool.test.ts
  • bun run typecheck
  • time bun src/index.ts --full — exits in ~1s (was ~120s tail)

Promise.race with uncancellable delay() left 120s timers on the event
loop after workers finished. Replace with explicit setTimeout +
clearTimeout on worker response and dispose.
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 26, 2026

🦋 Changeset detected

Latest commit: 09501e0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@stainless-code/codemap Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

Warning

Review limit reached

@SutuSebastian, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 44 minutes and 40 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 17aa26a9-ba62-43ee-be13-48d810aeb724

📥 Commits

Reviewing files that changed from the base of the PR and between 01d4931 and 09501e0.

📒 Files selected for processing (7)
  • .changeset/fix-worker-pool-exit-delay.md
  • .github/workflows/ci.yml
  • docs/architecture.md
  • src/application/parse-timeout.ts
  • src/worker-pool.dist.test.ts
  • src/worker-pool.test.ts
  • src/worker-pool.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/worker-pool-exit-delay

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 and usage tips.

Review follow-up: in-process wall time did not catch orphaned event-loop
timers. Spawn a child that runs parseFilesParallel and assert it exits in
<5s. Export INLINE_PARSE_MAX for fixture gate; remove unused delay().
Race child exit against 6s and kill on hang so regressions fail with a
clear assertion instead of burning the full test timeout.
Drop redundant 5s elapsed assertion; hang race is the regression signal.
Wrap Node dist --full smoke in timeout 45 so a timer leak fails CI fast.
Stop exporting INLINE_PARSE_MAX; mirror the threshold in tests. Add
node dist --full subprocess exit regression (skips when dist/ absent).
@SutuSebastian SutuSebastian merged commit 7afc9eb into main May 26, 2026
11 checks passed
@SutuSebastian SutuSebastian deleted the fix/worker-pool-exit-delay branch May 26, 2026 17:54
@github-actions github-actions Bot mentioned this pull request May 26, 2026
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