@cloudflare/sandbox 0.7.5 → 0.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as Process, A as RequestConfig, B as ExecResult, C as CommandClient, Ct as Execution, D as ContainerStub, E as BaseApiResponse, F as BucketCredentials, G as GitCheckoutResult, H as FileChunk, I as BucketProvider, J as LogEvent, K as ISandbox, L as DirectoryBackup, M as SessionRequest, N as BackupOptions, O as ErrorResponse, P as BaseExecOptions, Q as PortListResult, R as ExecEvent, S as WriteFileRequest, St as CreateContextOptions, T as BackupClient, Tt as RunCodeOptions, U as FileMetadata, V as ExecutionSession, W as FileStreamEvent, X as PortCloseResult, Y as MountBucketOptions, Z as PortExposeResult, _ as GitClient, _t as ExecuteRequest, a as CreateSessionRequest, at as ProcessOptions, b as MkdirRequest, bt as PtyOptions, c as DeleteSessionResponse, ct as RestoreBackupResult, d as ProcessClient, dt as StreamOptions, et as ProcessCleanupResult, f as PortClient, ft as WaitForLogResult, g as GitCheckoutRequest, gt as isProcessStatus, h as InterpreterClient, ht as isProcess, i as CommandsResponse, it as ProcessLogsResult, j as ResponseHandler, k as HttpClientOptions, l as PingResponse, lt as SandboxOptions, m as ExecutionCallbacks, mt as isExecResult, n as getSandbox, nt as ProcessKillResult, o as CreateSessionResponse, ot as ProcessStartResult, p as UnexposePortRequest, pt as WaitForPortOptions, q as ListFilesOptions, r as SandboxClient, rt as ProcessListResult, s as DeleteSessionRequest, st as ProcessStatus, t as Sandbox, tt as ProcessInfoResult, u as UtilityClient, ut as SessionOptions, v as FileClient, vt as ExposePortRequest, w as ExecuteResponse, wt as ExecutionResult, x as ReadFileRequest, xt as CodeContext, y as FileOperationRequest, yt as StartProcessRequest, z as ExecOptions } from "./sandbox-8qsR1OnB.js";
1
+ import { $ as Process, A as RequestConfig, B as ExecResult, C as CommandClient, Ct as Execution, D as ContainerStub, E as BaseApiResponse, F as BucketCredentials, G as GitCheckoutResult, H as FileChunk, I as BucketProvider, J as LogEvent, K as ISandbox, L as DirectoryBackup, M as SessionRequest, N as BackupOptions, O as ErrorResponse, P as BaseExecOptions, Q as PortListResult, R as ExecEvent, S as WriteFileRequest, St as CreateContextOptions, T as BackupClient, Tt as RunCodeOptions, U as FileMetadata, V as ExecutionSession, W as FileStreamEvent, X as PortCloseResult, Y as MountBucketOptions, Z as PortExposeResult, _ as GitClient, _t as ExecuteRequest, a as CreateSessionRequest, at as ProcessOptions, b as MkdirRequest, bt as PtyOptions, c as DeleteSessionResponse, ct as RestoreBackupResult, d as ProcessClient, dt as StreamOptions, et as ProcessCleanupResult, f as PortClient, ft as WaitForLogResult, g as GitCheckoutRequest, gt as isProcessStatus, h as InterpreterClient, ht as isProcess, i as CommandsResponse, it as ProcessLogsResult, j as ResponseHandler, k as HttpClientOptions, l as PingResponse, lt as SandboxOptions, m as ExecutionCallbacks, mt as isExecResult, n as getSandbox, nt as ProcessKillResult, o as CreateSessionResponse, ot as ProcessStartResult, p as UnexposePortRequest, pt as WaitForPortOptions, q as ListFilesOptions, r as SandboxClient, rt as ProcessListResult, s as DeleteSessionRequest, st as ProcessStatus, t as Sandbox, tt as ProcessInfoResult, u as UtilityClient, ut as SessionOptions, v as FileClient, vt as ExposePortRequest, w as ExecuteResponse, wt as ExecutionResult, x as ReadFileRequest, xt as CodeContext, y as FileOperationRequest, yt as StartProcessRequest, z as ExecOptions } from "./sandbox-DGAjk7r3.js";
2
2
  import { a as InvalidBackupConfigContext, c as ProcessReadyTimeoutContext, d as ErrorCode, i as BackupRestoreContext, l as ErrorResponse$1, n as BackupExpiredContext, r as BackupNotFoundContext, s as ProcessExitedBeforeReadyContext, t as BackupCreateContext, u as OperationType } from "./contexts-BHx40XTT.js";
3
3
 
4
4
  //#region src/errors/classes.d.ts
package/dist/index.js CHANGED
@@ -2698,7 +2698,7 @@ function buildS3fsSource(bucket, prefix) {
2698
2698
  * This file is auto-updated by .github/changeset-version.ts during releases
2699
2699
  * DO NOT EDIT MANUALLY - Changes will be overwritten on the next version bump
2700
2700
  */
2701
- const SDK_VERSION = "0.7.5";
2701
+ const SDK_VERSION = "0.7.6";
2702
2702
 
2703
2703
  //#endregion
2704
2704
  //#region src/sandbox.ts
@@ -3820,7 +3820,7 @@ var Sandbox = class Sandbox extends Container {
3820
3820
  * @param options - Configuration options
3821
3821
  * @param options.hostname - Your Worker's domain name (required for preview URL construction)
3822
3822
  * @param options.name - Optional friendly name for the port
3823
- * @param options.token - Optional custom token for the preview URL (1-16 characters: lowercase letters, numbers, hyphens, underscores)
3823
+ * @param options.token - Optional custom token for the preview URL (1-16 characters: lowercase letters, numbers, underscores)
3824
3824
  * If not provided, a random 16-character token will be generated automatically
3825
3825
  * @returns Preview URL information including the full URL, port number, and optional name
3826
3826
  *
@@ -3833,9 +3833,9 @@ var Sandbox = class Sandbox extends Container {
3833
3833
  * // With custom token for stable URLs across deployments
3834
3834
  * const { url } = await sandbox.exposePort(8080, {
3835
3835
  * hostname: 'example.com',
3836
- * token: 'my-token-v1'
3836
+ * token: 'my_token_v1'
3837
3837
  * });
3838
- * // url: https://8080-sandbox-id-my-token-v1.example.com
3838
+ * // url: https://8080-sandbox-id-my_token_v1.example.com
3839
3839
  */
3840
3840
  async exposePort(port, options) {
3841
3841
  if (!validatePort(port)) throw new SecurityError(`Invalid port number: ${port}. Must be 1024-65535, excluding 3000 (sandbox control plane).`);
@@ -4208,13 +4208,13 @@ var Sandbox = class Sandbox extends Container {
4208
4208
  "-X PUT",
4209
4209
  "-H 'Content-Type: application/octet-stream'",
4210
4210
  "--connect-timeout 10",
4211
- "--max-time 300",
4211
+ "--max-time 1800",
4212
4212
  "--retry 2",
4213
4213
  "--retry-max-time 60",
4214
- `--data-binary @${shellEscape(archivePath)}`,
4214
+ `-T ${shellEscape(archivePath)}`,
4215
4215
  shellEscape(presignedUrl)
4216
4216
  ].join(" ");
4217
- const result = await this.execWithSession(curlCmd, backupSession, { timeout: 31e4 });
4217
+ const result = await this.execWithSession(curlCmd, backupSession, { timeout: 181e4 });
4218
4218
  if (result.exitCode !== 0) throw new BackupCreateError({
4219
4219
  message: `Presigned URL upload failed (exit code ${result.exitCode}): ${result.stderr}`,
4220
4220
  code: ErrorCode.BACKUP_CREATE_FAILED,
@@ -4226,16 +4226,19 @@ var Sandbox = class Sandbox extends Container {
4226
4226
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
4227
4227
  });
4228
4228
  const head = await this.requireBackupBucket().head(r2Key);
4229
- if (!head || head.size !== archiveSize) throw new BackupCreateError({
4230
- message: `Upload verification failed: expected ${archiveSize} bytes, got ${head?.size ?? 0}`,
4231
- code: ErrorCode.BACKUP_CREATE_FAILED,
4232
- httpStatus: 500,
4233
- context: {
4234
- dir,
4235
- backupId
4236
- },
4237
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
4238
- });
4229
+ if (!head || head.size !== archiveSize) {
4230
+ const actualSize = head?.size ?? 0;
4231
+ throw new BackupCreateError({
4232
+ message: `Upload verification failed: expected ${archiveSize} bytes, got ${actualSize}.${result.exitCode === 0 && actualSize === 0 ? " This usually means the BACKUP_BUCKET R2 binding is using local storage while presigned URLs upload to remote R2. Add `\"remote\": true` to your BACKUP_BUCKET R2 binding in wrangler.jsonc to fix this." : ""}`,
4233
+ code: ErrorCode.BACKUP_CREATE_FAILED,
4234
+ httpStatus: 500,
4235
+ context: {
4236
+ dir,
4237
+ backupId
4238
+ },
4239
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
4240
+ });
4241
+ }
4239
4242
  }
4240
4243
  /**
4241
4244
  * Download a backup archive via presigned GET URL.
@@ -4254,13 +4257,13 @@ var Sandbox = class Sandbox extends Container {
4254
4257
  const curlCmd = [
4255
4258
  "curl -sSf",
4256
4259
  "--connect-timeout 10",
4257
- "--max-time 300",
4260
+ "--max-time 1800",
4258
4261
  "--retry 2",
4259
4262
  "--retry-max-time 60",
4260
4263
  `-o ${shellEscape(tmpPath)}`,
4261
4264
  shellEscape(presignedUrl)
4262
4265
  ].join(" ");
4263
- const result = await this.execWithSession(curlCmd, backupSession, { timeout: 31e4 });
4266
+ const result = await this.execWithSession(curlCmd, backupSession, { timeout: 181e4 });
4264
4267
  if (result.exitCode !== 0) {
4265
4268
  await this.execWithSession(`rm -f ${shellEscape(tmpPath)}`, backupSession).catch(() => {});
4266
4269
  throw new BackupRestoreError({