Skip to content

allow inline execution#219

Draft
ianmacartney wants to merge 1 commit intomainfrom
ian/inline-query-mutation
Draft

allow inline execution#219
ianmacartney wants to merge 1 commit intomainfrom
ian/inline-query-mutation

Conversation

@ianmacartney
Copy link
Member

@ianmacartney ianmacartney commented Mar 10, 2026

TL;DR

Added inline execution support for workflow queries and mutations, allowing them to run within the same transaction as the workflow instead of being dispatched through the work pool.

What changed?

  • Added shareTransaction option to workflow definitions that enables inline execution by default for queries and mutations
  • Added per-call inline option to override the default behavior for individual function calls
  • Implemented inline execution logic in startSteps that runs queries and mutations directly within the workflow transaction
  • Added comprehensive test suite covering sequential queries, parallel queries, Promise.race, mutations, mixed inline/action scenarios, and dependent queries
  • Updated type definitions to support the new inline functionality and made workId optional for inline steps

How to test?

Run the new test suite in example/convex/inlineTest.test.ts which covers:

  • Sequential inline queries completing in one poll
  • Parallel inline queries resolving in push order
  • Promise.race behavior with inline queries
  • Inline mutations executing within the same transaction
  • Per-call inline overrides
  • Mixed inline and action scenarios
  • Dependent inline queries where the second uses the first's result

Why make this change?

This change eliminates the round-trip overhead of dispatching queries and mutations through the work pool when they can safely execute within the workflow's transaction. This improves performance for workflows that primarily use queries and mutations, while maintaining the existing behavior for actions and providing flexibility through per-call overrides.

@coderabbitai
Copy link

coderabbitai bot commented Mar 10, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0b3abfaf-7ef1-404a-bd72-f13ec3215e4c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ian/inline-query-mutation

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

Copy link
Member Author

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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 10, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@convex-dev/workflow@219

commit: 3c471b5

@ianmacartney ianmacartney changed the title allow inline allow inline e Mar 10, 2026
@ianmacartney ianmacartney changed the title allow inline e allow inline execution Mar 10, 2026
@ianmacartney ianmacartney requested a review from reeceyang March 10, 2026 20:47
Comment on lines +91 to +93
// Only submit inline steps if all messages in the batch are inline.
// This ensures we only write journal entries when we have all responses.
const allInline = messages.every((m) => m.inline);
Copy link
Member Author

Choose a reason for hiding this comment

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

We should submit all and run what we can inline, we have a check below for only moving forward if we have results for every step we started (we don't want to make some progress on some promises that might not be the order they were resolved before - technically a prefix would be correct I think)

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