Skip to content

Commit

Permalink
Add timeout to resume request
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentaTomas committed Nov 12, 2024
1 parent eaccd6e commit b0b74ea
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
13 changes: 13 additions & 0 deletions packages/js-sdk/src/api/schema.gen.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/js-sdk/src/sandbox/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ export class Sandbox extends SandboxApi {
static async resume<S extends typeof Sandbox>(
this: S,
sandboxId: string,
opts?: Pick<SandboxOpts, 'requestTimeoutMs'>
opts?: Pick<SandboxOpts, 'requestTimeoutMs' | 'timeoutMs'>
): Promise<InstanceType<S>> {
const id = await Sandbox.resumeSandbox(sandboxId, opts)
const id = await Sandbox.resumeSandbox(sandboxId, opts?.timeoutMs ?? this.defaultSandboxTimeoutMs, opts)

return this.connect(id, opts)
}
Expand Down
4 changes: 4 additions & 0 deletions packages/js-sdk/src/sandbox/sandboxApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ export class SandboxApi {

protected static async resumeSandbox(
sandboxId: string,
timeoutMs: number,
opts?: SandboxApiOpts
): Promise<string> {
const config = new ConnectionConfig(opts)
Expand All @@ -198,6 +199,9 @@ export class SandboxApi {
sandboxID: sandboxId,
},
},
body: {
timeout: this.timeoutToSeconds(timeoutMs),
},
})

if (res.error?.code === 404) {
Expand Down
15 changes: 15 additions & 0 deletions spec/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,15 @@ components:
envVars:
$ref: "#/components/schemas/EnvVars"

ResumedSandbox:
properties:
timeout:
type: integer
format: int32
minimum: 0
default: 15
description: Time to live for the sandbox in seconds.

Template:
required:
- templateID
Expand Down Expand Up @@ -471,6 +480,12 @@ paths:
- ApiKeyAuth: []
parameters:
- $ref: "#/components/parameters/sandboxID"
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/ResumedSandbox"
responses:
"201":
description: The sandbox was resumed successfully
Expand Down

0 comments on commit b0b74ea

Please sign in to comment.