{"record":{"id":"9d96c9ef6761b62a","repo":"run-llama/liteparse","slug":"parse-of-source-exceeded-this-timeoutms-ms-t","errorCode":null,"errorMessage":"parse of ${source} exceeded ${this.timeoutMs}ms; the worker process was killed","messagePattern":"parse of (.+?) exceeded (.+?)ms; the worker process was killed","errorType":"exception","errorClass":"ParseTimeoutError","httpStatus":null,"severity":"error","filePath":"packages/node/src/pool.ts","lineNumber":262,"sourceCode":"    if (!this.closed) this.spawnWorker();\n  }\n\n  /** Run one parse on an idle worker.\n   *\n   * Waits for a free worker first; `parseTimeoutMs` bounds the parse itself,\n   * not the wait. */\n  async parse(payload: string | Buffer, source: string): Promise<ParseResult> {\n    if (this.closed) throw new Error(\"parser pool is closed\");\n    const worker = await this.acquire();\n    try {\n      await worker.ready();\n      const result = await worker.request(payload, this.timeoutMs);\n      this.release(worker);\n      return result;\n    } catch (e) {\n      this.retire(worker);\n      if (e instanceof WorkerTimeout) {\n        throw new ParseTimeoutError(\n          `parse of ${source} exceeded ${this.timeoutMs}ms; the worker process was killed`,\n          source,\n          this.timeoutMs!,\n        );\n      }\n      if (e instanceof WorkerCrashed) {\n        throw new Error(\n          `liteparse worker process died while parsing ${source}: ${e.message}`,\n        );\n      }\n      throw e;\n    }\n  }\n\n  /** Resolves when every worker is initialized. Optional — the first parse\n   * per worker waits for init anyway. */\n  async warmUp(): Promise<void> {\n    await Promise.all([...this.workers].map((w) => w.ready()));","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/run-llama/liteparse/blob/22d2dd8cd7f7b9320102b57ddaf0e663ff7d15a8/packages/node/src/pool.ts#L244-L280","documentation":"When a parse on a pool worker exceeds the configured parseTimeoutMs, the pool kills the worker process and throws ParseTimeoutError with the source name and the timeout that was exceeded. The offending worker is retired, so the pool remains usable for subsequent parses. This bounds the parse itself, not the wait for a free worker.","triggerScenarios":"Parsing a huge or pathologically complex PDF with `parseTimeoutMs` set (e.g. 5000ms) via `pool.parse(payload, source)`; a timeout configured too aggressively for large documents; a worker stuck in native PDFium code.","commonSituations":"Scanned documents triggering OCR within the parse; 500+ page PDFs with a default-sized timeout; production timeouts tuned on small test files then applied to real workloads.","solutions":["Raise `parseTimeoutMs` to a value that accommodates your largest documents.","Catch ParseTimeoutError and fall back to a longer-timeout pool or a non-pooled parse for that document.","Pre-screen documents (page count/size) and route big ones to a pool with a larger timeout.","Set a timeout of undefined (disable) if unbounded parses are acceptable.","Investigate why the document is slow (OCR settings, page count) if most parses time out."],"exampleFix":"// before\nconst pool = new WorkerPool(cfg, 2, 5000);\n// after\nconst pool = new WorkerPool(cfg, 2, 60000);\ntry {\n  await pool.parse(buf, 'big.pdf');\n} catch (e) {\n  if (e instanceof ParseTimeoutError) { /* retry with larger pool/timeout */ }\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"import { statSync } from 'fs';\nconst mb = statSync(path).size / 1e6;\nconst timeoutMs = mb > 50 ? 120000 : 15000; // scale timeout to document size","typeGuard":null,"tryCatchPattern":"import { ParseTimeoutError } from './pool.js';\ntry {\n  result = await pool.parse(buf, source);\n} catch (e) {\n  if (e instanceof ParseTimeoutError) {\n    result = await slowPool.parse(buf, source); // pool with larger parseTimeoutMs\n  } else throw e;\n}","preventionTips":["Size parseTimeoutMs from your largest real documents, not test files.","Route large/OCR-heavy documents to a dedicated pool with a bigger timeout.","Alert on ParseTimeoutError rates to catch regressions in document complexity.","Remember the timeout bounds the parse only; queue wait is not counted."],"tags":["worker-pool","timeout","parse"],"backgroundTag":"request-timeout","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"}