feat(js): add experimental sandbox memory snapshot support#233
Open
willydouhard wants to merge 1 commit intomodal-labs:mainfrom
Open
feat(js): add experimental sandbox memory snapshot support#233willydouhard wants to merge 1 commit intomodal-labs:mainfrom
willydouhard wants to merge 1 commit intomodal-labs:mainfrom
Conversation
Add support for experimental memory snapshots in the JavaScript/TypeScript SDK: - Add `_experimentalEnableSnapshot` option to `SandboxCreateParams` - Add `experimentalOptions` for server-side feature flags - Add `SandboxSnapshot` class for snapshot management - Add `_experimentalSnapshot()` method on `Sandbox` to create snapshots - Add `_experimentalFromSnapshot()` method on `SandboxService` to restore from snapshots - Fix missing `forcePathStyle` in CloudBucketMount proto conversion
| sandboxId: this.sandboxId, | ||
| }); | ||
|
|
||
| const snapshotId = snapResp.snapshotId; |
There was a problem hiding this comment.
Bug: Missing validation for snapshotId from API response
The _experimentalSnapshot method uses snapResp.snapshotId without validating it exists. If the API response is missing snapshotId, it would pass an undefined/empty value to sandboxSnapshotWait and return a SandboxSnapshot with an invalid ID. The analogous snapshotFilesystem method validates resp.imageId before use with a check like if (!resp.imageId) throw new Error(...).
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
SandboxSnapshotclass and_experimentalSnapshot()/_experimentalFromSnapshot()methods for creating and restoring sandbox memory snapshotsexperimentalOptionsparameter toSandboxCreateParamsfor server-side feature flagsforcePathStylefield inCloudBucketMountproto conversionChanges
New Features
sandbox._experimentalSnapshot(): Takes a memory snapshot of a running sandboxsandboxes._experimentalFromSnapshot(snapshot, params): Restores a sandbox from a snapshotSandboxSnapshotclass: Represents a stored sandbox snapshot_experimentalEnableSnapshotoption inSandboxCreateParams: Enables memory snapshots for a sandboxexperimentalOptionsinSandboxCreateParams: Pass experimental feature flags to the serverBug Fixes
forcePathStyle: falsetoCloudBucketMount.toProto()Test Plan
buildSandboxCreateRequestProtowith new experimental optionsNote
Adds experimental sandbox memory snapshot create/restore APIs, exposes
SandboxSnapshot, supports experimental options in create params, and fixes missingforcePathStylein cloud bucket mount proto.Sandbox#_experimentalSnapshot()to create memory snapshots and wait for completion.SandboxService#_experimentalFromSnapshot()to restore fromSandboxSnapshotwith optional name override handling.SandboxSnapshotclass andSandboxFromSnapshotParamstype.SandboxCreateParamswithexperimentalOptionsand_experimentalEnableSnapshot; includeexperimentalOptionsandenableSnapshotin create request proto.SandboxSnapshotandSandboxFromSnapshotParamsfromindex.ts.forcePathStyle: falseinCloudBucketMount#toProto().experimentalOptions,_experimentalEnableSnapshot, and their defaults inbuildSandboxCreateRequestProto.Written by Cursor Bugbot for commit f90f057. This will update automatically on new commits. Configure here.