Skip to content

Commit fe1d51f

Browse files
committed
Fix test compatibility for setInactivityTimeout
1 parent b411779 commit fe1d51f

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/lib/container.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -585,9 +585,12 @@ export class Container<Env = unknown> extends DurableObject<Env> {
585585
if (this.container.running) {
586586
const timeoutInMs = parseTimeExpression(this.sleepAfter) * 1000;
587587
// Type assertion needed until @cloudflare/workers-types is updated
588-
(this.container as any).setInactivityTimeout(timeoutInMs).catch((error: any) => {
589-
console.error('Failed to set inactivity timeout:', error);
590-
});
588+
const containerAny = this.container as any;
589+
if (typeof containerAny.setInactivityTimeout === 'function') {
590+
containerAny.setInactivityTimeout(timeoutInMs).catch((error: any) => {
591+
console.error('Failed to set inactivity timeout:', error);
592+
});
593+
}
591594
}
592595
}
593596

0 commit comments

Comments
 (0)