{"record":{"id":"1b29343482e15f75","repo":"run-llama/liteparse","slug":"parsetimeoutms-must-be-0","errorCode":null,"errorMessage":"parseTimeoutMs must be > 0","messagePattern":"parseTimeoutMs must be > 0","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/node/src/pool.ts","lineNumber":205,"sourceCode":"  private timeoutMs: number | undefined;\n  private workers = new Set<WorkerHandle>();\n  private idle: WorkerHandle[] = [];\n  private waiters: Array<{\n    resolve: (w: WorkerHandle) => void;\n    reject: (e: Error) => void;\n  }> = [];\n  private closed = false;\n\n  constructor(\n    config: Record<string, unknown>,\n    poolSize: number,\n    parseTimeoutMs?: number,\n  ) {\n    if (!Number.isInteger(poolSize) || poolSize < 1) {\n      throw new Error(\"poolSize must be an integer >= 1\");\n    }\n    if (parseTimeoutMs !== undefined && !(parseTimeoutMs > 0)) {\n      throw new Error(\"parseTimeoutMs must be > 0\");\n    }\n    this.config = config;\n    this.timeoutMs = parseTimeoutMs;\n    // Spawn eagerly: children load the addon and construct their native\n    // parsers concurrently while the caller goes on with its own startup.\n    for (let i = 0; i < poolSize; i++) {\n      this.spawnWorker();\n    }\n  }\n\n  private spawnWorker(): void {\n    const worker = new WorkerHandle(this.config);\n    this.workers.add(worker);\n    this.release(worker);\n  }\n\n  private acquire(): Promise<WorkerHandle> {\n    const worker = this.idle.pop();","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/run-llama/liteparse/blob/22d2dd8cd7f7b9320102b57ddaf0e663ff7d15a8/packages/node/src/pool.ts#L187-L223","documentation":"WorkerPool validates that parseTimeoutMs, when provided, is a positive number (> 0). A zero or negative timeout would abort every parse instantly, so the constructor rejects it up front. Passing undefined disables timeouts entirely and is allowed.","triggerScenarios":"`new WorkerPool(config, 2, 0)` or `-1000`; computing a timeout from a mis-parsed duration string yielding 0 or NaN (NaN fails `NaN > 0` too); a config UI or env var supplying 0 meaning 'no timeout' when the API expects undefined for that.","commonSituations":"Env parsing `Number('0')` from PARSE_TIMEOUT_MS=0 intended as 'disabled'; unit tests passing 0; mixing seconds/milliseconds conversions that produce 0 for sub-second values.","solutions":["Pass a positive millisecond value, e.g. `new WorkerPool(config, 2, 30000)`.","Pass `undefined` (omit the argument) to disable timeouts instead of 0.","Sanitize: `const t = timeoutMs && timeoutMs > 0 ? timeoutMs : undefined;`"],"exampleFix":"// before\nconst pool = new WorkerPool(cfg, 2, Number(process.env.PARSE_TIMEOUT_MS ?? 0));\n// after\nconst raw = Number(process.env.PARSE_TIMEOUT_MS);\nconst pool = new WorkerPool(cfg, 2, raw > 0 ? raw : undefined);","handlingStrategy":"validation","validationCode":"const t = Number(process.env.PARSE_TIMEOUT_MS);\nconst timeoutMs = Number.isFinite(t) && t > 0 ? t : undefined;\nif (process.env.PARSE_TIMEOUT_MS !== undefined && timeoutMs === undefined) {\n  console.warn('Ignoring non-positive PARSE_TIMEOUT_MS; timeouts disabled');\n}","typeGuard":"const isValidTimeout = (v) => v === undefined || (typeof v === 'number' && Number.isFinite(v) && v > 0);","tryCatchPattern":"let pool;\ntry {\n  pool = new WorkerPool(config, size, timeoutMs);\n} catch (e) {\n  if (e.message === 'parseTimeoutMs must be > 0') {\n    pool = new WorkerPool(config, size, 30000);\n  } else throw e;\n}","preventionTips":["Remember 0 does not mean 'disabled' — omit the value for no timeout.","Check unit conversions (seconds vs ms) that can floor to 0.","Use a config validator schema for timeout fields (positive number or undefined)."],"tags":["worker-pool","configuration","timeout"],"backgroundTag":"value-out-of-range","analyzedSha":"22d2dd8cd7f7b9320102b57ddaf0e663ff7d15a8","analyzedAt":"2026-09-08T06:09:49.009Z","contentChangedAt":"2026-09-08T06:09:49.009Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}