-
Notifications
You must be signed in to change notification settings - Fork 158
Add support for serializing this when invoking step functions
#754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for serializing this when invoking step functions
#754
Conversation
🦋 Changeset detectedLatest commit: 15c9b77 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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🧪 E2E Test Results❌ Some tests failed Summary
❌ Failed Tests🌍 Community Worlds (21 failed)mongodb (1 failed):
redis (1 failed):
starter (18 failed):
turso (1 failed):
Details by Category✅ ▲ Vercel Production
✅ 💻 Local Development
✅ 📦 Local Production
✅ 🐘 Local Postgres
✅ 🪟 Windows
❌ 🌍 Community Worlds
|
This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for serializing the this context when invoking step functions, enabling the use of JavaScript's .call() and .apply() methods with step functions.
- Modified step function creation to use a regular function instead of an arrow function to capture
thiscontext - Added optional
thisValproperty to the step invocation queue item interface - Enhanced serialization/deserialization flow to handle
thisValalongside existingargsandclosureVars
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/core/src/step.ts | Changed to regular function to capture this and conditionally serialize it when not undefined/null/globalThis |
| packages/core/src/global.ts | Added optional thisVal property to StepInvocationQueueItem interface |
| packages/core/src/runtime/suspension-handler.ts | Included thisVal in the dehydrated step input |
| packages/core/src/runtime/step-handler.ts | Hydrated and applied thisVal when executing step functions, updated comment |
| workbench/example/workflows/99_e2e.ts | Added example workflow demonstrating .call() and .apply() usage with step functions |
| packages/core/e2e/e2e.test.ts | Added e2e test validating thisSerializationWorkflow behavior |
| .changeset/old-pugs-win.md | Added changeset documenting the patch-level change |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
7b4e431 to
2dc4f99
Compare
572c60b to
15c9b77
Compare
📊 Benchmark Results
workflow with no steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) | Nitro | Express workflow with 1 step💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) | Express workflow with 10 sequential steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) | Nitro | Express Promise.all with 10 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) | Express Promise.all with 25 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) | Express Promise.race with 10 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) | Express Promise.race with 25 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Express | Next.js (Turbopack) Stream Benchmarks (includes TTFB metrics)workflow with stream💻 Local Development
▲ Production (Vercel)
🔍 Observability: Express | Nitro | Next.js (Turbopack) SummaryFastest Framework by WorldWinner determined by most benchmark wins
Fastest World by FrameworkWinner determined by most benchmark wins
Column Definitions
Worlds:
|

Added support for serializing
thiscontext when invoking step functions.What changed?
thiscontext when it's defined and not the global objectthisValpropertythisValwhen executing step functionsWhy make this change?
This enhancement allows step functions to be invoked with an explicit context object using standard JavaScript methods like
.call()and.apply(). This is particularly useful for step functions that need to access properties from a specific context, enabling more flexible and idiomatic JavaScript patterns within workflows.