Skip to content

Commit cbcda36

Browse files
committed
fix types casting
1 parent 47817bf commit cbcda36

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

packages/sandbox/src/sandbox.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ export function getSandbox(
4545
}
4646

4747
if (options?.sleepAfter !== undefined) {
48-
// Set sleepAfter property on the stub
49-
// Cast to any to work around RPC type inference issues
50-
(stub as any).sleepAfter = options.sleepAfter;
48+
stub.setSleepAfter(options.sleepAfter);
5149
}
5250

5351
return stub;
@@ -127,6 +125,11 @@ export class Sandbox<Env = unknown> extends Container<Env> implements ISandbox {
127125
}
128126
}
129127

128+
// RPC method to set the sleep timeout
129+
async setSleepAfter(sleepAfter: string | number): Promise<void> {
130+
this.sleepAfter = sleepAfter;
131+
}
132+
130133
// RPC method to set environment variables
131134
async setEnvVars(envVars: Record<string, string>): Promise<void> {
132135
// Update local state for new sessions

packages/sandbox/tests/get-sandbox.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ describe('getSandbox', () => {
2727
sleepAfter: '3m',
2828
setSandboxName: vi.fn(),
2929
setBaseUrl: vi.fn(),
30+
setSleepAfter: vi.fn((value: string | number) => {
31+
mockStub.sleepAfter = value;
32+
}),
3033
};
3134

3235
// Mock getContainer to return our stub

0 commit comments

Comments
 (0)