{"record":{"id":"47d52170429c1085","repo":"nodejs/node","slug":"und-err-invalid-arg-47d521","errorCode":"UND_ERR_INVALID_ARG","errorMessage":"invalid connections","messagePattern":"invalid connections","errorType":"validation","errorClass":"InvalidArgumentError","httpStatus":null,"severity":"error","filePath":"deps/undici/src/lib/dispatcher/pool.js","lineNumber":45,"sourceCode":"\nclass Pool extends PoolBase {\n  constructor (origin, {\n    connections,\n    factory = defaultFactory,\n    connect,\n    connectTimeout,\n    tls,\n    maxCachedSessions,\n    socketPath,\n    autoSelectFamily,\n    autoSelectFamilyAttemptTimeout,\n    allowH2,\n    useH2c,\n    clientTtl,\n    ...options\n  } = {}) {\n    if (connections != null && (!Number.isFinite(connections) || connections < 0)) {\n      throw new InvalidArgumentError('invalid connections')\n    }\n\n    if (typeof factory !== 'function') {\n      throw new InvalidArgumentError('factory must be a function.')\n    }\n\n    if (connect != null && typeof connect !== 'function' && typeof connect !== 'object') {\n      throw new InvalidArgumentError('connect must be a function or an object')\n    }\n\n    if (typeof connect !== 'function') {\n      connect = buildConnector({\n        ...tls,\n        maxCachedSessions,\n        allowH2,\n        useH2c,\n        socketPath,\n        timeout: connectTimeout,","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/undici/src/lib/dispatcher/pool.js#L27-L63","documentation":"Thrown by the Pool constructor when the connections option is present but either not finite (NaN/Infinity) or negative. Pool needs a non-negative number of upstream client connections to manage; an invalid value would break the connection-counting loop used for distribution.","triggerScenarios":"Passing connections: -1, NaN, Infinity, or a non-number. The guard connections != null && (!Number.isFinite(connections) || connections < 0) lets 0 through (which Pool interprets as auto/infinite). Floats like 1.5 pass Number.isFinite but are usually unintended.","commonSituations":"Env var or config string not coerced to a number; arithmetic that yields NaN (e.g. undefined - 1); typo passing connectionCount under the wrong key; infinity used to mean 'unlimited' (use 0 instead).","solutions":["Set connections to a non-negative finite integer, or use 0 to let Pool size automatically.","Coerce and validate numeric config: Number.isFinite(x) && x >= 0 before passing.","If you meant unlimited, pass 0 rather than Infinity.","Check for typos in the option key name."],"exampleFix":"// before\nnew Pool(url, { connections: parseInt(process.env.POOL_SIZE) }) // NaN when unset\n// after\nconst c = Number(process.env.POOL_SIZE)\nnew Pool(url, { connections: Number.isFinite(c) && c >= 0 ? c : undefined })","handlingStrategy":"validation","validationCode":"function resolveConnections(v) {\n  if (v == null) return undefined\n  if (!Number.isFinite(v) || v < 0) throw new Error('connections must be a non-negative finite number')\n  return v\n}\nnew Pool(url, { connections: resolveConnections(cfg.connections) })","typeGuard":"function isValidConnections(v) { return v == null || (Number.isFinite(v) && v >= 0) }","tryCatchPattern":null,"preventionTips":["Use 0 (not Infinity) for auto-sized pools.","Coerce config strings with Number() and validate finiteness.","Watch for NaN from undefined arithmetic."],"tags":["undici","pool","config","invalid-arg"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}