Skip to content

Commit b49102c

Browse files
committed
Add a 24-hour timeout limit to workspace timeouts
1 parent a9bdfe5 commit b49102c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

components/gitpod-protocol/src/gitpod-service.ts

+8
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,8 @@ export interface ClientHeaderFields {
358358
clientRegion?: string;
359359
}
360360

361+
const WORKSPACE_MAXIMUM_TIMEOUT_HOURS = 24;
362+
361363
export type WorkspaceTimeoutDuration = string;
362364
export namespace WorkspaceTimeoutDuration {
363365
export function validate(duration: string): WorkspaceTimeoutDuration {
@@ -369,6 +371,12 @@ export namespace WorkspaceTimeoutDuration {
369371
if (isNaN(value) || value <= 0) {
370372
throw new Error(`Invalid timeout value: ${duration}`);
371373
}
374+
if (
375+
(unit === "h" && value > WORKSPACE_MAXIMUM_TIMEOUT_HOURS) ||
376+
(unit === "m" && value > WORKSPACE_MAXIMUM_TIMEOUT_HOURS * 60)
377+
) {
378+
throw new Error(`Timeouts cannot extend to more than a day`);
379+
}
372380
return duration;
373381
}
374382
}

0 commit comments

Comments
 (0)