-
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
base: 01-08-support_class_static_methods_with_use_step___use_workflow_
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 572c60b 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
|
|
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.
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
4e49fd8 to
ff9e014
Compare
12811e7 to
2a729f4
Compare

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.