Skip to content

Conversation

@TooTallNate
Copy link
Member

@TooTallNate TooTallNate commented Nov 19, 2025

Added support for closure variables in serialized step functions, allowing step functions to access variables from their lexical scope when executed remotely.

What changed?

  • Modified the step function serialization format to include closure variables
  • Updated the StepFunction reducer to capture and serialize closure variables
  • Enhanced the StepFunction reviver to restore closure variables in the execution context
  • Added a wrapper function that sets up the proper context with closure variables when the step function is invoked
  • Added tests to verify that step functions can access closure variables after serialization and deserialization

Why 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.

@changeset-bot
Copy link

changeset-bot bot commented Nov 19, 2025

🦋 Changeset detected

Latest commit: 76cb745

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@workflow/core Patch
@workflow/builders Patch
@workflow/cli Patch
@workflow/next Patch
@workflow/nitro Patch
@workflow/web-shared Patch
workflow Patch
@workflow/sveltekit Patch
@workflow/world-testing Patch
@workflow/nuxt Patch
@workflow/ai Patch

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

@vercel
Copy link
Contributor

vercel bot commented Nov 19, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
example-nextjs-workflow-turbopack Ready Ready Preview Comment Nov 20, 2025 8:10am
example-nextjs-workflow-webpack Ready Ready Preview Comment Nov 20, 2025 8:10am
example-workflow Ready Ready Preview Comment Nov 20, 2025 8:10am
workbench-express-workflow Ready Ready Preview Comment Nov 20, 2025 8:10am
workbench-hono-workflow Ready Ready Preview Comment Nov 20, 2025 8:10am
workbench-nitro-workflow Ready Ready Preview Comment Nov 20, 2025 8:10am
workbench-nuxt-workflow Ready Ready Preview Comment Nov 20, 2025 8:10am
workbench-sveltekit-workflow Ready Ready Preview Comment Nov 20, 2025 8:10am
workbench-vite-workflow Ready Ready Preview Comment Nov 20, 2025 8:10am
workflow-docs Ready Ready Preview Comment Nov 20, 2025 8:10am

Copy link
Member Author

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.
Learn more

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

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.

2 participants