fix(sandbox): add workflow serialization support for Snapshot class#140
Open
TooTallNate wants to merge 1 commit intomainfrom
Open
fix(sandbox): add workflow serialization support for Snapshot class#140TooTallNate wants to merge 1 commit intomainfrom
TooTallNate wants to merge 1 commit intomainfrom
Conversation
Snapshot instances returned from workflow steps failed serialization because the class lacked WORKFLOW_SERIALIZE/WORKFLOW_DESERIALIZE methods. Add these methods following the same lazy-client pattern used by Sandbox and Command, ensuring credentials are never serialized.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR adds workflow runtime serialization/deserialization support for Snapshot instances in @vercel/sandbox, aligning Snapshot with the existing Sandbox/Command lazy-client pattern so snapshots can safely cross workflow/step boundaries without serializing credentials.
Changes:
- Added
WORKFLOW_SERIALIZE/WORKFLOW_DESERIALIZEstatic methods toSnapshot, serializing onlySnapshotMetadataand lazily recreating the API client viaensureClient()when needed. - Updated
Snapshotinstance methods to use the lazy client initialization path (so deserialized instances still work for API calls). - Added a dedicated Vitest suite covering roundtrips, credential exclusion, and workflow runtime pipeline hydration/dehydration.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/vercel-sandbox/src/snapshot.ts | Implements workflow serde hooks and lazy client initialization for deserialized Snapshot instances. |
| packages/vercel-sandbox/src/snapshot.serialize.test.ts | Adds integration + unit tests for Snapshot serialization behavior and runtime step-boundary roundtrips. |
| packages/vercel-sandbox/src/index.ts | Re-exports SerializedSnapshot type for consumers. |
| .changeset/snapshot-workflow-serialization.md | Adds a patch changeset documenting the serialization fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
WORKFLOW_SERIALIZE/WORKFLOW_DESERIALIZEstatic methods to theSnapshotclass, fixing serialization errors when aSnapshotinstance is returned from a workflow step.SandboxandCommand: only plainSnapshotMetadatais serialized (credentials are excluded), and an API client is lazily created viaensureClient()when needed after deserialization.dehydrate/hydratethrough the workflow runtime pipeline.