{"record":{"id":"d5b8b1b8f42fc099","repo":"nodejs/node","slug":"invalid-connections","errorCode":null,"errorMessage":"invalid connections","messagePattern":"invalid connections","errorType":"exception","errorClass":"InvalidArgumentError","httpStatus":null,"severity":"error","filePath":"deps/undici/src/lib/dispatcher/round-robin-pool.js","lineNumber":45,"sourceCode":"}\n\nclass RoundRobinPool 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    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        socketPath,\n        timeout: connectTimeout,\n        ...(typeof autoSelectFamily === 'boolean' ? { autoSelectFamily, autoSelectFamilyAttemptTimeout } : undefined),","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/undici/src/lib/dispatcher/round-robin-pool.js#L27-L63","documentation":"Thrown by the RoundRobinPool constructor when the connections option is present but not finite (NaN/Infinity) or negative. RoundRobinPool spreads requests across N upstream clients; an invalid connections count would break the round-robin index arithmetic. The guard is identical to Pool's: connections != null && (!Number.isFinite(connections) || connections < 0).","triggerScenarios":"Passing connections: -1, NaN, Infinity, a non-number, or a numeric string that was not parsed. 0 is allowed (Pool treats it as auto-sizing).","commonSituations":"Env-driven config parsed as a string; arithmetic yielding NaN; using Infinity to mean 'unlimited'; sharing a config object between Pool and RoundRobinPool where the value was tuned for one and is invalid for the other.","solutions":["Set connections to a non-negative finite integer, or pass 0 / omit it for auto-sizing.","Coerce numeric config with Number.isFinite checks before passing.","Use 0 (not Infinity) when you want the pool to size itself.","Validate the value in a shared config helper used by both Pool and RoundRobinPool."],"exampleFix":"// before\nnew RoundRobinPool(url, { connections: Infinity })\n// after\nnew RoundRobinPool(url, { connections: 10 })","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 RoundRobinPool(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-sizing.","Coerce string config with Number() and check Number.isFinite.","Share a single numeric-config validator between Pool and RoundRobinPool."],"tags":["undici","round-robin-pool","config","invalid-arg"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}