{"record":{"id":"d07847df7fc79e70","repo":"nodejs/node","slug":"und-err-invalid-arg-d07847","errorCode":"UND_ERR_INVALID_ARG","errorMessage":"http module not available or http.maxHeaderSize invalid","messagePattern":"http module not available or http\\.maxHeaderSize invalid","errorType":"validation","errorClass":"InvalidArgumentError","httpStatus":null,"severity":"critical","filePath":"deps/undici/src/lib/dispatcher/client.js","lineNumber":69,"sourceCode":"  kMaxResponseSize,\n  kOnError,\n  kHTTPContext,\n  kMaxConcurrentStreams,\n  kHostAuthority,\n  kResume,\n  kHTTP2Options\n} = require('../core/symbols.js')\nconst connectH1 = require('./client-h1.js')\nconst connectH2 = require('./client-h2.js')\n\nconst kClosedResolve = Symbol('kClosedResolve')\n\nconst getDefaultNodeMaxHeaderSize = http &&\n  http.maxHeaderSize &&\n  Number.isInteger(http.maxHeaderSize) &&\n  http.maxHeaderSize > 0\n  ? () => http.maxHeaderSize\n  : () => { throw new InvalidArgumentError('http module not available or http.maxHeaderSize invalid') }\n\nconst noop = () => { }\n\nfunction getPipelining (client) {\n  return client[kPipelining] ?? client[kHTTPContext]?.defaultPipelining ?? 1\n}\n\nlet h2NamespaceOptsWarning = false\nfunction emitH2OptionsNamespaceWarning (optName) {\n  if (h2NamespaceOptsWarning === true) return\n\n  process.emitWarning(`Use h2Options.${optName} instead. ${optName} for H2 will be deprecated in future major.`, {\n    code: 'UNDICI-H2-OPTIONS'\n  })\n  h2NamespaceOptsWarning = true\n}\n\n// Protocol-aware dispatch ceiling. h1 RFC7230 pipelining is unrelated to h2","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/undici/src/lib/dispatcher/client.js#L51-L87","documentation":"Thrown by getDefaultNodeMaxHeaderSize in client.js when Node's built-in http module is missing OR http.maxHeaderSize is not a positive integer. The Client reads Node's default header-size limit lazily; if the host environment is non-conformant (a stripped Node build, a broken bundler, or http.maxHeaderSize manually set to a bad value), undici cannot derive a safe default and refuses to construct rather than silently use an unsafe limit.","triggerScenarios":"Running undici in an environment where require('http') is undefined or where http.maxHeaderSize was set to 0 / a negative / a non-integer before the Client is constructed.","commonSituations":"Bundling undici for a non-Node runtime (browser/electron renderer without Node core); a polyfill that omits maxHeaderSize; a startup script that sets http.maxHeaderSize = 0; a corrupted Node installation.","solutions":["Run on a standard Node.js release where require('http').maxHeaderSize is a positive integer.","Remove any code that sets http.maxHeaderSize to a non-positive or non-integer value.","If you must override the limit, pass maxHeaderSize explicitly in the Client options (a positive integer).","In bundlers, mark 'http' as external or use a runtime that provides Node core."],"exampleFix":"// before — somewhere at startup\nrequire('http').maxHeaderSize = 0\nconst client = new Client(origin) // throws\n// after — do not zero out the default, or pass an explicit value\nconst client = new Client(origin, { maxHeaderSize: 16384 })","handlingStrategy":"validation","validationCode":"const http = require('http')\nfunction assertHttpEnv() {\n  if (!http || !Number.isInteger(http.maxHeaderSize) || http.maxHeaderSize <= 0) {\n    throw new Error('Node http module unavailable or http.maxHeaderSize invalid')\n  }\n}\nassertHttpEnv()\nconst client = new Client(origin, { maxHeaderSize: 16384 }) // explicit, env-independent","typeGuard":"function httpEnvOk() {\n  const http = require('http')\n  return !!http && Number.isInteger(http.maxHeaderSize) && http.maxHeaderSize > 0\n}","tryCatchPattern":null,"preventionTips":["Run on a standard Node.js runtime; keep 'http' external in bundlers.","Never assign http.maxHeaderSize to a non-positive or non-integer value.","Pass an explicit maxHeaderSize to Client so it does not depend on the ambient default."],"tags":["undici","client","http-module","environment","maxheadersize"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}