fix(agentrun): bound events timeout to 60m
This commit is contained in:
@@ -360,12 +360,12 @@ function parsePositiveInt(raw: string | null, flag: string): number {
|
||||
|
||||
export function parseDurationMs(raw: string | null, flag: string): number {
|
||||
if (raw === null || raw.length === 0) throw new Error(`${flag} requires a duration`);
|
||||
const match = /^(\d+)(ms|s|m|h)$/u.exec(raw.trim());
|
||||
if (match === null) throw new Error(`${flag} must use an integer duration such as 500ms, 120s, 3m, or 1h`);
|
||||
const match = /^(\d+)(ms|s|m)$/u.exec(raw.trim());
|
||||
if (match === null) throw new Error(`${flag} must use a positive integer duration with ms, s, or m units, such as 500ms, 120s, or 3m`);
|
||||
const amount = Number(match[1]);
|
||||
const multiplier = match[2] === "ms" ? 1 : match[2] === "s" ? 1_000 : match[2] === "m" ? 60_000 : 3_600_000;
|
||||
const multiplier = match[2] === "ms" ? 1 : match[2] === "s" ? 1_000 : 60_000;
|
||||
const value = amount * multiplier;
|
||||
if (!Number.isSafeInteger(value) || value < 1 || value > 86_400_000) throw new Error(`${flag} must be between 1ms and 24h`);
|
||||
if (!Number.isSafeInteger(value) || value < 1 || value > 3_600_000) throw new Error(`${flag} must be between 1ms and 60m`);
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user