fix: add Node event-bus logging and awaitable worker.stop() - #540
Conversation
|
Warning Review limit reached
Next review available in: 56 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughNode worker shutdown now returns a promise that completes after worker-scoped resource disposal. Event listener throws and rejections are debug-logged while sibling listeners continue executing. Documentation, CLI shutdown handling, and tests were updated accordingly. ChangesNode robustness updates
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/content/docs/shared/guides/core/workers.mdx`:
- Around line 478-479: Update the worker shutdown example to await the existing
worker.stop() call directly rather than invoking worker.stop() twice, preserving
the documented in-flight draining and resource teardown behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 5ee18069-30d2-4cfd-9f53-09ca08f664af
📒 Files selected for processing (9)
CHANGELOG.mddocs/content/docs/node/api-reference/worker.mdxdocs/content/docs/node/guides/resources/dependency-injection.mdxdocs/content/docs/shared/guides/core/workers.mdxsdks/node/src/cli/commands/run.tssdks/node/src/events.tssdks/node/src/worker.tssdks/node/test/resources/resources.test.tssdks/node/test/worker/emitter.test.ts
Fixes #521 — the two Node robustness items from the SDK parity audit.
Event bus (
sdks/node/src/events.ts)Emitter.emit()isolated listener throws and async rejections but logged nothing, so amisbehaving listener was invisible. Both paths now
log.debugwith the event name and theerror; isolation is unchanged.
Worker.stop()(sdks/node/src/worker.ts)stop()firedresources.teardownWorker()fire-and-forget, returning before worker-scopedresources were disposed — surprising in test teardown. It now returns
Promise<void>thatresolves once teardown completes. Dispatch, the heartbeat, log consumers,
native.stop()andthe
worker.stoppedemit all still run synchronously before the promise is returned, so callersthat ignore the result behave exactly as before. The promise never rejects; teardown failures are
logged.
taskito runawaits it before exiting.Tests
test/worker/emitter.test.ts— throwing listener logged and siblings still run, asyncrejection logged, no output when listeners behave.
test/resources/resources.test.ts—await worker.stop()observes a slowdisposeasfinished, with no polling.
Docs updated: Node worker API reference, workers guide, dependency-injection teardown section,
plus a CHANGELOG entry per fix.
Local run:
biome checkclean, targeted tests pass, full suite 422 passed. The 10 dashboard testfiles fail in
beforeAllonpnpm run build:dashboard(vitenot installed indashboard/) —pre-existing environment gap, unrelated to these changes.
Summary by CodeRabbit
worker.stop()now returns a promise that completes after worker-scoped resources are disposed.worker.stop().