Support step function serialization in "client" mode#924
Conversation
🦋 Changeset detectedLatest commit: cee25ef The changes in this PR will be included in the next version bump. This PR includes changesets to release 15 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
🧪 E2E Test Results❌ Some tests failed Summary
❌ Failed Tests🌍 Community Worlds (163 failed)mongodb (40 failed):
redis (40 failed):
starter (42 failed):
turso (41 failed):
Details by Category✅ ▲ Vercel Production
✅ 💻 Local Development
✅ 📦 Local Production
✅ 🐘 Local Postgres
✅ 🪟 Windows
❌ 🌍 Community Worlds
✅ 📋 Other
|
This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Pull request overview
This PR adds support for step function serialization in client mode by registering step functions and setting their stepId property. This enables step functions to be properly serialized when passed as arguments to start() or returned from other step functions.
Changes:
- Modified the SWC plugin to call
registerStepFunction()on step functions in client mode - Updated
registerStepFunctioninpackages/core/src/private.tsto set thestepIdproperty on functions for serialization support - Added a custom
StepFunctionreviver ingetWorkflowReviversthat wraps deserialized step functions with theuseStepwrapper when in workflow context, allowing them to be called directly from workflow code - Updated test fixtures to include
registerStepFunctioncalls and necessary imports in client mode outputs - Added an E2E test and example code demonstrating step functions being passed as arguments to
start()
Reviewed changes
Copilot reviewed 33 out of 33 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/core/src/private.ts | Added stepId property to StepFunction type and modified registerStepFunction to set it |
| packages/core/src/serialization.ts | Added custom StepFunction reviver in getWorkflowRevivers that returns useStep wrapper in workflow context |
| packages/swc-plugin-workflow/transform/src/lib.rs | Modified client mode transformation to register step functions and added import generation |
| packages/swc-plugin-workflow/spec.md | Updated documentation to reflect client mode step registration |
| workbench/example/workflows/99_e2e.ts | Added test workflow and step functions for E2E testing |
| workbench/example/api/trigger.ts | Added support for injecting step function references as test arguments |
| packages/core/e2e/e2e.test.ts | Added E2E test for step function serialization |
| Multiple test fixtures | Updated expected outputs to include registerStepFunction calls |
| .changeset/*.md | Added changeset entries for the changes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/swc-plugin-workflow/transform/tests/fixture/nested-step-with-closure/output-client.js
Outdated
Show resolved
Hide resolved
8cee6a5 to
ef23b0b
Compare
fe7612d to
2f41523
Compare
2f41523 to
cee25ef
Compare
📊 Benchmark Results
workflow with no steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Express | Next.js (Turbopack) | Nitro workflow with 1 step💻 Local Development
▲ Production (Vercel)
🔍 Observability: Express | Nitro | Next.js (Turbopack) workflow with 10 sequential steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) | Express workflow with 25 sequential steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) | Express workflow with 50 sequential steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) | Nitro | Express Promise.all with 10 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Express | Nitro | Next.js (Turbopack) Promise.all with 25 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Express | Next.js (Turbopack) | Nitro Promise.all with 50 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) | Express Promise.race with 10 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Express | Nitro | Next.js (Turbopack) Promise.race with 25 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) | Express | Nitro Promise.race with 50 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) | Express | Nitro Stream Benchmarks (includes TTFB metrics)workflow with stream💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) | Express SummaryFastest Framework by WorldWinner determined by most benchmark wins
Fastest World by FrameworkWinner determined by most benchmark wins
Column Definitions
Worlds:
|

Added support for step function serialization in client mode by setting the
stepIdproperty and registering step functions.What changed?
stepIdproperty to step functions inregisterStepFunctionto support serializationregisterStepFunction()on step functions in client moderegisterStepFunctionin client mode outputHow to test?
Why make this change?
This change enables proper serialization of step functions in client mode. Previously, step functions in client mode weren't registered, which meant they couldn't be properly serialized when passed as arguments to
start()or returned from other step functions. By setting thestepIdproperty and registering step functions in client mode, we ensure consistent behavior between client and server modes when step functions are passed across boundaries.