Skip to content

Comments

chore: update workflow queues api#4230

Closed
NathanFlurry wants to merge 1 commit into02-18-chore_simplify_queue_apifrom
02-18-chore_update_workflow_queues_api
Closed

chore: update workflow queues api#4230
NathanFlurry wants to merge 1 commit into02-18-chore_simplify_queue_apifrom
02-18-chore_update_workflow_queues_api

Conversation

@NathanFlurry
Copy link
Member

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@railway-app railway-app bot temporarily deployed to rivet-frontend / rivet-pr-4230 February 19, 2026 07:43 Destroyed
@railway-app
Copy link

railway-app bot commented Feb 19, 2026

🚅 Deployed to the rivet-pr-4230 environment in rivet-frontend

Service Status Web Updated (UTC)
ladle ❌ Build Failed (View Logs) Web Feb 19, 2026 at 10:40 pm
website ✅ Success (View Logs) Web Feb 19, 2026 at 10:08 pm
frontend-cloud ❌ Build Failed (View Logs) Web Feb 19, 2026 at 7:45 am
frontend-inspector ❌ Build Failed (View Logs) Web Feb 19, 2026 at 7:44 am
mcp-hub ✅ Success (View Logs) Web Feb 19, 2026 at 7:44 am

Copy link
Member Author

NathanFlurry commented Feb 19, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


How to use the Graphite Merge Queue

Add the label merge-queue to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@NathanFlurry NathanFlurry mentioned this pull request Feb 19, 2026
11 tasks
@claude
Copy link

claude bot commented Feb 19, 2026

PR Review: chore: update workflow queues api

This PR replaces the listen* method family (listen, listenN, listenWithTimeout, listenUntil, listenNWithTimeout, listenNUntil) with a unified ctx.queue.next(name, opts) API. It also removes the workflowQueueName() prefix wrapper, making actor queue names and workflow queue names identical. Overall this is a good API consolidation, but there are a few concerns to address.


Critical: History Compatibility

The most significant risk is breaking existing in-flight workflows. Two independent changes affect history replay:

  1. History key layout changed. The old listenUntil stored history under ${name} (sleep) and ${name}:message (message). The new executeQueueNext uses ${name}:count, ${name}:deadline, and ${name}:0. Any workflow currently sleeping in a listenUntil or listenWithTimeout will hit HistoryDivergedError on its next run.

  2. History marker renamed. LISTEN_HISTORY_MESSAGE_MARKER (__rivetWorkflowListenMessage) → QUEUE_HISTORY_MESSAGE_MARKER (__rivetWorkflowQueueMessage). Entries written by the old code will fall through to the legacy deserialization path in fromHistoryQueueMessage, which recovers the data field but loses id, name, and createdAt. This is probably tolerable but worth confirming.

If any workflows are running in production (or in long-lived tests), they will fail after this deploy. A migration strategy or a compatibility shim for old history entries should be considered.


Behavioral Change: Batch Collection

The old listenNUntil accumulated messages iteratively across multiple yield-resume cycles — it would collect one message per run, yield, then collect another. The new queue.next with count > 1 does a single consumeMessages call per run. This means partial batches are only possible if fewer than count messages are already in the queue at the moment of the call, not if they arrive across multiple cycles. This is a subtle but real behavioral difference for patterns that relied on incremental accumulation.


waitingForMessages !== undefined vs length > 0

In rivetkit-typescript/packages/workflow-engine/src/index.ts:

-const hasMessages =
-    result.waitingForMessages && result.waitingForMessages.length > 0;
+const hasMessages = result.waitingForMessages !== undefined;

If waitingForMessages is ever an empty array (e.g., from a queue.next with names: []/wildcard match that yields with no specific names), the live executor will enter the message-wait path unnecessarily. The old guard was tighter. Worth verifying whether waitingForMessages: [] is a valid state.


Indentation Noise in context.ts

The checkDuplicateName body in WorkflowContextImpl gained an extra level of indentation without a structural change. Similar whitespace drift appears in several test blocks in messages.test.ts. Probably not functional, but adds noise to the diff and may cause lint failures.


Minor: history-examples.ts Semantic Equivalence

Replacing listenUntil(name, queue, Date.now() + 300) with queue.next(name, { timeout: 300 }) is semantically equivalent since executeQueueNext converts the relative timeout to an absolute deadline on first run. No issue here, but Date.now() is now called slightly later (inside executeQueueNext rather than at call site). Should be unobservable in practice.


Positive Observations

  • The unified ctx.queue.next() API is a significant ergonomic improvement — one method replaces six with orthogonal options.
  • Removing workflowQueueName() eliminates the impedance mismatch between actor queue keys and workflow message names.
  • ctx.queue.send() is a useful addition that was missing before.
  • TypeScript type inference for queue body types and event types now flows correctly through the workflow context hierarchy and into loop/join/race callbacks.
  • The receiveMessages() driver hook cleanly allows actor-backed workflows to reuse native queue semantics without double-buffering.
  • The pendingCompletableMessageIds guard is a good safety mechanism, and the new tests covering it are thorough.
  • New expectTypeOf type tests in actor-types.test.ts are a good addition.

Summary

The API design is sound and the implementation is well-thought-out. The primary concern before merging is the history compatibility issue for any workflows currently mid-execution. If this is a fresh system or all workflows can be drained/restarted, the risk is low. Otherwise, a compatibility layer for old history entries or a coordinated migration is needed.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 19, 2026

More templates

@rivetkit/cloudflare-workers

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/cloudflare-workers@4230

@rivetkit/framework-base

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/framework-base@4230

@rivetkit/next-js

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/next-js@4230

@rivetkit/react

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/react@4230

rivetkit

pnpm add https://pkg.pr.new/rivet-dev/rivet/rivetkit@4230

@rivetkit/sql-loader

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/sql-loader@4230

@rivetkit/sqlite-vfs

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/sqlite-vfs@4230

@rivetkit/traces

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/traces@4230

@rivetkit/workflow-engine

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/workflow-engine@4230

@rivetkit/virtual-websocket

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/virtual-websocket@4230

@rivetkit/engine-runner

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/engine-runner@4230

@rivetkit/engine-runner-protocol

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/engine-runner-protocol@4230

commit: 67f79b0

@NathanFlurry NathanFlurry marked this pull request as ready for review February 19, 2026 08:12
@NathanFlurry NathanFlurry force-pushed the 02-18-chore_simplify_queue_api branch from b9aca01 to ee35c6c Compare February 19, 2026 19:40
@NathanFlurry NathanFlurry force-pushed the 02-18-chore_update_workflow_queues_api branch from 480b364 to b9a7d4c Compare February 19, 2026 19:40
@railway-app railway-app bot temporarily deployed to rivet-frontend / rivet-pr-4230 February 19, 2026 19:40 Destroyed
@NathanFlurry NathanFlurry force-pushed the 02-18-chore_simplify_queue_api branch from ee35c6c to 8d79ee3 Compare February 19, 2026 19:54
@NathanFlurry NathanFlurry force-pushed the 02-18-chore_update_workflow_queues_api branch from b9a7d4c to 67f79b0 Compare February 19, 2026 19:54
@railway-app railway-app bot temporarily deployed to rivet-frontend / rivet-pr-4230 February 19, 2026 19:54 Destroyed
@NathanFlurry NathanFlurry force-pushed the 02-18-chore_update_workflow_queues_api branch from 67f79b0 to 8400de3 Compare February 19, 2026 22:12
@railway-app railway-app bot temporarily deployed to rivet-frontend / rivet-pr-4230 February 19, 2026 22:12 Destroyed
@NathanFlurry NathanFlurry mentioned this pull request Feb 19, 2026
11 tasks
@NathanFlurry NathanFlurry force-pushed the 02-18-chore_update_workflow_queues_api branch from 8400de3 to 67f79b0 Compare February 19, 2026 22:40
@NathanFlurry NathanFlurry force-pushed the 02-18-chore_simplify_queue_api branch from 8b13f68 to 8d79ee3 Compare February 19, 2026 22:40
@graphite-app
Copy link
Contributor

graphite-app bot commented Feb 19, 2026

Merge activity

  • Feb 19, 10:44 PM UTC: NathanFlurry added this pull request to the Graphite merge queue.
  • Feb 19, 10:45 PM UTC: CI is running for this pull request on a draft pull request (#4238) due to your merge queue CI optimization settings.
  • Feb 19, 10:45 PM UTC: Merged by the Graphite merge queue via draft PR: #4238.

graphite-app bot pushed a commit that referenced this pull request Feb 19, 2026
# Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

## Type of change

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update

## How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

## Checklist:

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
@graphite-app graphite-app bot closed this Feb 19, 2026
@graphite-app graphite-app bot deleted the 02-18-chore_update_workflow_queues_api branch February 19, 2026 22:45
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