π File detail
utils/timeouts.ts
π§© .tsπ 40 linesπΎ 1,410 bytesπ text
β Back to All Filesπ― Use case
This file lives under βutils/β, which covers cross-cutting helpers (shell, tempfiles, settings, messages, process input, β¦). On the API surface it exposes getDefaultBashTimeoutMs and getMaxBashTimeoutMs β mainly functions, hooks, or classes.
Generated from folder role, exports, dependency roots, and inline comments β not hand-reviewed for every path.
π§ Inline summary
// Constants for timeout values const DEFAULT_TIMEOUT_MS = 120_000 // 2 minutes const MAX_TIMEOUT_MS = 600_000 // 10 minutes type EnvLike = Record<string, string | undefined>
π€ Exports (heuristic)
getDefaultBashTimeoutMsgetMaxBashTimeoutMs
π₯οΈ Source preview
// Constants for timeout values
const DEFAULT_TIMEOUT_MS = 120_000 // 2 minutes
const MAX_TIMEOUT_MS = 600_000 // 10 minutes
type EnvLike = Record<string, string | undefined>
/**
* Get the default timeout for bash operations in milliseconds
* Checks BASH_DEFAULT_TIMEOUT_MS environment variable or returns 2 minutes default
* @param env Environment variables to check (defaults to process.env for production use)
*/
export function getDefaultBashTimeoutMs(env: EnvLike = process.env): number {
const envValue = env.BASH_DEFAULT_TIMEOUT_MS
if (envValue) {
const parsed = parseInt(envValue, 10)
if (!isNaN(parsed) && parsed > 0) {
return parsed
}
}
return DEFAULT_TIMEOUT_MS
}
/**
* Get the maximum timeout for bash operations in milliseconds
* Checks BASH_MAX_TIMEOUT_MS environment variable or returns 10 minutes default
* @param env Environment variables to check (defaults to process.env for production use)
*/
export function getMaxBashTimeoutMs(env: EnvLike = process.env): number {
const envValue = env.BASH_MAX_TIMEOUT_MS
if (envValue) {
const parsed = parseInt(envValue, 10)
if (!isNaN(parsed) && parsed > 0) {
// Ensure max is at least as large as default
return Math.max(parsed, getDefaultBashTimeoutMs(env))
}
}
// Always ensure max is at least as large as default
return Math.max(MAX_TIMEOUT_MS, getDefaultBashTimeoutMs(env))
}