Skip to content

feat: expand Node events to full cross-SDK taxonomy - #537

Merged
pratyush618 merged 5 commits into
masterfrom
feat/node-event-taxonomy
Jul 24, 2026
Merged

feat: expand Node events to full cross-SDK taxonomy#537
pratyush618 merged 5 commits into
masterfrom
feat/node-event-taxonomy

Conversation

@kartikeya-27

@kartikeya-27 kartikeya-27 commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Grows the event surface from the 4 job-outcome events to the 26-name cross-SDK taxonomy: job.enqueued, per-attempt job.failed, worker lifecycle (started/online/stopped/offline/unhealthy), queue.paused/resumed, workflow submit/terminal/gate, saga compensation, and predicate.rejected.

  • queue.on()/off() are now generically typed: the handler payload is inferred from the event name via EventMap. The original four events and OutcomeEvent are unchanged.
  • job.failed fires on every attempt failure, before the retry/dead decision from the outcome stream.
  • Terminal workflow events fire once per run (bounded dedup guard) and carry the run's error.
  • Webhooks can subscribe to every event name; task-filtered webhooks only filter task-bearing events; deliveries for task-less events store null task/job identity.
  • The kind-to-event mapping is now a single shared constant (was duplicated between the worker and webhook manager).
  • workflow.cancelled is 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

    • Expanded event support across jobs, queues, workers, workflows, gates, and compensations.
    • Added strongly typed event subscriptions and payloads.
    • Added queue pause/resume, job enqueue, worker lifecycle, and workflow lifecycle notifications.
    • Webhooks can now subscribe to and deliver the expanded event set.
    • Added configurable worker heartbeat intervals.
  • Bug Fixes

    • Listener failures no longer interrupt other event handlers.
    • Improved handling of task-less webhook events and delivery metadata.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@pratyush618, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 32 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

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.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ad9f6e27-4952-4e22-8962-5f55e778905f

📥 Commits

Reviewing files that changed from the base of the PR and between b381120 and 73b8fbe.

📒 Files selected for processing (2)
  • sdks/node/src/worker.ts
  • sdks/node/test/workflows/dag.test.ts
📝 Walkthrough

Walkthrough

The 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.

Changes

Typed event contracts

Layer / File(s) Summary
Centralized event contracts
sdks/node/src/events.ts, sdks/node/src/index.ts, sdks/node/src/queue.ts
Event names, payload interfaces, event mappings, typed handlers, listener isolation, and public exports are expanded.
Queue and worker event emission
sdks/node/src/queue.ts, sdks/node/src/worker.ts, sdks/node/src/types.ts, sdks/node/test/core/*, sdks/node/test/worker/*
Queue operations emit enqueue, predicate, and pause/resume events; workers emit outcome and lifecycle events with heartbeat tracking and configurable cadence.
Workflow lifecycle and compensation events
sdks/node/src/workflows/*, sdks/node/test/workflows/*
Workflow submission, terminal, gate, cancellation, and saga compensation events are emitted through the shared emitter with terminal deduplication.
Webhook event subscriptions and delivery
sdks/node/src/webhooks/*, sdks/node/test/core/webhook*
Webhook subscriptions derive from the centralized event list, delivery accepts heterogeneous payloads, and task-less event metadata is handled explicitly.

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
Loading

Possibly related PRs

Suggested labels: tests

Suggested reviewers: pratyush618

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main change: expanding Node events to the full cross-SDK taxonomy.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/node-event-taxonomy

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.

@github-actions github-actions Bot added the tests label Jul 24, 2026
pratyush618
pratyush618 previously approved these changes Jul 24, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Handle cancelled compensation jobs through settleCancelledJob().

settleCancelledJob() checks only workflowNodeForJob, so a cancelled rollback job is no-operated even though onOutcome()'s success/dead branch first checks compensationNodeForJob. If that rollback is the last compensation job in flight, the run never re-invokes advanceCompensation() and can remain in compensating. 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

📥 Commits

Reviewing files that changed from the base of the PR and between 2ed64a8 and b381120.

📒 Files selected for processing (19)
  • sdks/node/src/events.ts
  • sdks/node/src/index.ts
  • sdks/node/src/queue.ts
  • sdks/node/src/types.ts
  • sdks/node/src/webhooks/deliverer.ts
  • sdks/node/src/webhooks/manager.ts
  • sdks/node/src/worker.ts
  • sdks/node/src/workflows/manager.ts
  • sdks/node/src/workflows/tracker.ts
  • sdks/node/test/core/predicates.test.ts
  • sdks/node/test/core/queue-events.test.ts
  • sdks/node/test/core/webhookStoreContract.test.ts
  • sdks/node/test/core/webhooks.test.ts
  • sdks/node/test/worker/events.test.ts
  • sdks/node/test/worker/lifecycle-events.test.ts
  • sdks/node/test/workflows/dag.test.ts
  • sdks/node/test/workflows/gates.test.ts
  • sdks/node/test/workflows/saga.test.ts
  • sdks/node/test/workflows/subworkflows.test.ts

Comment thread sdks/node/src/worker.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants