-
Notifications
You must be signed in to change notification settings - Fork 137
Support closure variables for serialized step functions #366
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
Support closure variables for serialized step functions #366
Conversation
🦋 Changeset detectedLatest commit: a431eb2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 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.
|
This stack of pull requests is managed by Graphite. Learn more about stacking. |
| Object.defineProperty(wrappedStepFn, 'name', { | ||
| value: stepFn.name, | ||
| }); | ||
| Object.defineProperty(wrappedStepFn, 'stepId', { |
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.
I'd prefer if we renamed stepId in this PR to stepName or similar to avoid future confusion with actual stepIDs like step_<ulid>
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.
That's fair. I named it as such here to be analogous to the workflowId property which follows the similar string format.
stepName/workflowName is perhaps less ambiguous, but in actuality the string contains both a filename and the step/workflow name. I wonder if we can pick a name that properly encompasses both pieces of information (location?). Anyways, if we do change the name let's do for both step+workflow in a separate PR.
Merge activity
|
7e5fe40 to
40ab768
Compare
2854b16 to
247fa49
Compare
247fa49 to
a431eb2
Compare

Added support for closure variables in serialized step functions, allowing step functions to access variables from their lexical scope when executed remotely.
What changed?
StepFunctionreducer to capture and serialize closure variablesStepFunctionreviver to restore closure variables in the execution contextWhy make this change?
Previously, serialized step functions could only access their arguments when executed remotely, but not variables from their lexical scope. This limitation made it difficult to write reusable step functions that needed to access shared configuration or context. This change enables more natural programming patterns by allowing step functions to access closure variables, making the code more intuitive and reducing the need to pass all context as function arguments.