feat: expand Node events to full cross-SDK taxonomy - #537
Conversation
|
Warning Review limit reached
Next review available in: 32 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 (2)
📝 WalkthroughWalkthroughThe Node SDK centralizes event names and payload types, adds typed emitter APIs, emits queue, worker, and workflow lifecycle events, and expands webhook delivery to support all event payload shapes. Tests cover event ordering, payloads, deduplication, compensation, and webhook subscriptions. ChangesTyped event contracts
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Queue
participant Emitter
participant Worker
participant WorkflowTracker
participant WebhookManager
Queue->>Emitter: emit queue or enqueue event
Worker->>Emitter: emit outcome or lifecycle event
WorkflowTracker->>Emitter: emit workflow event
Emitter->>WebhookManager: dispatch event payload
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
sdks/node/src/workflows/tracker.ts (1)
131-162: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winHandle cancelled compensation jobs through
settleCancelledJob().
settleCancelledJob()checks onlyworkflowNodeForJob, so a cancelled rollback job is no-operated even thoughonOutcome()'s success/dead branch first checkscompensationNodeForJob. If that rollback is the last compensation job in flight, the run never re-invokesadvanceCompensation()and can remain incompensating. Mirror the compensation check and route the cancelled rollback back through compensation status handling.🤖 Prompt for 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. In `@sdks/node/src/workflows/tracker.ts` around lines 131 - 162, The cancelled branch in onOutcome must handle compensation jobs before calling settleCancelledJob. Check compensationNodeForJob(outcome.jobId) and route cancelled rollback outcomes through the existing compensation status handling, ensuring the final in-flight compensation re-invokes advanceCompensation; retain settleCancelledJob for ordinary workflow jobs and the current no-op behavior for unrelated jobs.
🤖 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 `@sdks/node/src/worker.ts`:
- Around line 310-330: Update the worker lifecycle state used by stop() and
sendHeartbeat() so stopping marks the worker as stopped before clearing the
interval. Guard the workerHeartbeat() promise continuation, including before and
during reentrant offline-event delivery, so it cannot emit worker.online or
worker.offline after worker.stopped; preserve normal heartbeat event behavior
while running.
---
Outside diff comments:
In `@sdks/node/src/workflows/tracker.ts`:
- Around line 131-162: The cancelled branch in onOutcome must handle
compensation jobs before calling settleCancelledJob. Check
compensationNodeForJob(outcome.jobId) and route cancelled rollback outcomes
through the existing compensation status handling, ensuring the final in-flight
compensation re-invokes advanceCompensation; retain settleCancelledJob for
ordinary workflow jobs and the current no-op behavior for unrelated jobs.
🪄 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: 425257f4-b59e-4e30-861a-12d1e94365e5
📒 Files selected for processing (19)
sdks/node/src/events.tssdks/node/src/index.tssdks/node/src/queue.tssdks/node/src/types.tssdks/node/src/webhooks/deliverer.tssdks/node/src/webhooks/manager.tssdks/node/src/worker.tssdks/node/src/workflows/manager.tssdks/node/src/workflows/tracker.tssdks/node/test/core/predicates.test.tssdks/node/test/core/queue-events.test.tssdks/node/test/core/webhookStoreContract.test.tssdks/node/test/core/webhooks.test.tssdks/node/test/worker/events.test.tssdks/node/test/worker/lifecycle-events.test.tssdks/node/test/workflows/dag.test.tssdks/node/test/workflows/gates.test.tssdks/node/test/workflows/saga.test.tssdks/node/test/workflows/subworkflows.test.ts
Grows the event surface from the 4 job-outcome events to the 26-name cross-SDK taxonomy:
job.enqueued, per-attemptjob.failed, worker lifecycle (started/online/stopped/offline/unhealthy),queue.paused/resumed, workflow submit/terminal/gate, saga compensation, andpredicate.rejected.queue.on()/off()are now generically typed: the handler payload is inferred from the event name viaEventMap. The original four events andOutcomeEventare unchanged.job.failedfires on every attempt failure, before the retry/dead decision from the outcome stream.error.workflow.cancelledis reserved: there is no run-cancellation API in this SDK yet, so it only fires if the finalizer reports a cancelled run.No native/Rust changes. 506 vitest tests green (19 added), tsc and biome clean.
Part of #535.
Summary by CodeRabbit
New Features
Bug Fixes