run-llama/liteparse · error · Error
poolSize must be an integer >= 1
Error message
poolSize must be an integer >= 1
What it means
WorkerPool's constructor validates that poolSize is a whole number of at least 1 before spawning workers. A non-integer (0.5, NaN, Infinity) or a value below 1 would produce a broken or empty pool, so it throws immediately. This is a fail-fast guard for programmatic configuration mistakes.
Solutions
- Pass an integer >= 1: `new WorkerPool(config, 4)`.
- Sanitize env-derived values: `const n = Math.max(1, Math.floor(Number(process.env.POOL_SIZE ?? 2)))`.
- Guard before construction: `if (!Number.isInteger(poolSize) || poolSize < 1) poolSize = 2;`
Example fix
// before const pool = new WorkerPool(cfg, Number(process.env.POOL_SIZE)); // after const n = Math.max(1, Math.floor(Number(process.env.POOL_SIZE) || 2)); const pool = new WorkerPool(cfg, n);
Defensive patterns
Strategy: validation
Validate before calling
const n = Math.floor(Number(process.env.POOL_SIZE));
if (!Number.isInteger(n) || n < 1) {
throw new Error(`POOL_SIZE must be an integer >= 1, got ${process.env.POOL_SIZE}`);
} Type guard
const isValidPoolSize = (v) => typeof v === 'number' && Number.isInteger(v) && v >= 1;
Try / catch
let pool;
try {
pool = new WorkerPool(config, poolSize, timeoutMs);
} catch (e) {
if (e.message === 'poolSize must be an integer >= 1') {
pool = new WorkerPool(config, 2, timeoutMs);
} else throw e;
} Prevention
- Sanitize env-derived numbers with Number.isInteger before use.
- Use Math.max(1, Math.floor(x)) for computed pool sizes.
- Avoid raw user input flowing into poolSize.
When it happens
Trigger: `new WorkerPool(config, 0)`, a fractional poolSize from computing `maxWorkers / 2`, or NaN/undefined leaking from env parsing like `Number(process.env.POOL_SIZE)` when the variable is unset or garbage.
Common situations: Env-var-driven config where POOL_SIZE is empty string (Number('') === 0); dividing a worker count and flooring incorrectly; passing user-supplied values straight into the pool config.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- parseTimeoutMs requires poolSize
- parseTimeoutMs must be > 0
- pool_size must be >= 1
- parse_timeout must be > 0 seconds
- parse_timeout requires pool_size
AI-assisted analysis of run-llama/liteparse@22d2dd8cd7 (2026-09-08).
Data as JSON: /api/errors/3a84bdd254874470.
Report an issue: GitHub.
Appendix: source
Thrown at packages/node/src/pool.ts:202
export class WorkerPool {
private config: Record<string, unknown>;
private timeoutMs: number | undefined;
private workers = new Set<WorkerHandle>();
private idle: WorkerHandle[] = [];
private waiters: Array<{
resolve: (w: WorkerHandle) => void;
reject: (e: Error) => void;
}> = [];
private closed = false;
constructor(
config: Record<string, unknown>,
poolSize: number,
parseTimeoutMs?: number,
) {
if (!Number.isInteger(poolSize) || poolSize < 1) {
throw new Error("poolSize must be an integer >= 1");
}
if (parseTimeoutMs !== undefined && !(parseTimeoutMs > 0)) {
throw new Error("parseTimeoutMs must be > 0");
}
this.config = config;
this.timeoutMs = parseTimeoutMs;
// Spawn eagerly: children load the addon and construct their native
// parsers concurrently while the caller goes on with its own startup.
for (let i = 0; i < poolSize; i++) {
this.spawnWorker();
}
}
private spawnWorker(): void {
const worker = new WorkerHandle(this.config);
this.workers.add(worker);
this.release(worker);
}View on GitHub (pinned to 22d2dd8cd7)