JuliusBrussee/caveman · error · Error
timeoutMs must be a positive integer
Error message
timeoutMs must be a positive integer
What it means
Error "timeoutMs must be a positive integer" thrown in JuliusBrussee/caveman.
Source
Thrown at packages/sdk/typescript/src/index.ts:356
try {
parsed = new URL(value);
} catch {
throw new Error(`${name} must be an absolute http(s) URL`);
}
if ((parsed.protocol !== "http:" && parsed.protocol !== "https:") || !parsed.hostname || parsed.username || parsed.password) {
throw new Error(`${name} must be an absolute http(s) URL without credentials`);
}
if (parsed.search || parsed.hash) throw new Error(`${name} must not contain a query or fragment`);
return value.replace(/\/+$/, "");
}
export class Cave {
readonly options: CaveOptions;
constructor(options: CaveOptions) {
if (!options.apiKey || !options.baseURL || !options.agent) throw new Error("apiKey, baseURL, and agent are required");
if (options.timeoutMs !== undefined && (!Number.isSafeInteger(options.timeoutMs) || options.timeoutMs <= 0)) {
throw new Error("timeoutMs must be a positive integer");
}
// CAVE_WORKFLOW lets a wrapper (`cave wrap --workflow x`) label every request
// from an SDK app without a code change. An explicit option always wins.
// globalThis lookup keeps the SDK browser-neutral (no node type dependency).
// The env value is normalized to the gateway's label rule (lowercase
// [a-z0-9_-], max 96) — an invalid ambient value is ignored rather than
// 400-ing every request. Mirrors caveman_cloud (Python).
const envRaw = (globalThis as { process?: { env?: Record<string, string | undefined> } }).process?.env?.["CAVE_WORKFLOW"]?.toLowerCase();
const envWorkflow = envRaw && /^[a-z0-9_-]{1,96}$/.test(envRaw) ? envRaw : undefined;
const normalized: CaveOptions = {
...options,
baseURL: normalizedServiceURL(options.baseURL, "baseURL"),
...(options.controlURL === undefined
? {}
: { controlURL: normalizedServiceURL(options.controlURL, "controlURL") }),
};
this.options = !normalized.defaultWorkflow && envWorkflow
? { ...normalized, defaultWorkflow: envWorkflow }View on GitHub (pinned to 27d5a3981a)
Solutions
- Set timeoutMs to a positive integer.
When it happens
Trigger: Thrown at packages/sdk/typescript/src/index.ts:356 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
AI-assisted analysis of JuliusBrussee/caveman@27d5a3981a (2026-08-15).
Data as JSON: /api/errors/3f2a43c969502d39.
Report an issue: GitHub.