{"record":{"id":"28ccaf64e329f654","repo":"nodejs/node","slug":"und-err-invalid-arg-28ccaf","errorCode":"UND_ERR_INVALID_ARG","errorMessage":"maxSize must be a number greater than 0","messagePattern":"maxSize must be a number greater than 0","errorType":"validation","errorClass":"InvalidArgumentError","httpStatus":null,"severity":"error","filePath":"deps/undici/src/lib/interceptor/dump.js","lineNumber":16,"sourceCode":"'use strict'\n\nconst { InvalidArgumentError, RequestAbortedError } = require('../core/errors')\nconst DecoratorHandler = require('../handler/decorator-handler')\n\nclass DumpHandler extends DecoratorHandler {\n  #maxSize = 1024 * 1024\n  #dumped = false\n  #size = 0\n  #controller = null\n  aborted = false\n  reason = false\n\n  constructor ({ maxSize, signal }, handler) {\n    if (maxSize != null && (!Number.isFinite(maxSize) || maxSize < 1)) {\n      throw new InvalidArgumentError('maxSize must be a number greater than 0')\n    }\n\n    super(handler)\n\n    this.#maxSize = maxSize ?? this.#maxSize\n    // this.#handler = handler\n  }\n\n  #abort (reason) {\n    this.aborted = true\n    this.reason = reason\n  }\n\n  onRequestStart (controller, context) {\n    controller.abort = this.#abort.bind(this)\n    this.#controller = controller\n\n    return super.onRequestStart(controller, context)","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/undici/src/lib/interceptor/dump.js#L1-L34","documentation":"Thrown by the dump interceptor's `DumpHandler` constructor (`InvalidArgumentError`, code `UND_ERR_INVALID_ARG`) when `maxSize` is provided and is either not finite or less than 1. The dump interceptor reads and discards response bodies up to a cap so that request hooks (redirect handling, retry decisions) can see the response without buffering huge payloads; `maxSize` (default 1 MiB) is the byte ceiling it enforces. Values below 1 or non-finite (`NaN`, `Infinity`) are rejected because they make the cap meaningless.","triggerScenarios":"Passing `maxSize: 0`, a negative number, `NaN`, a string, or `Infinity`. Constructed via `new DumpHandler({ maxSize }, handler)` or through the interceptor with `dumpMaxSize` in dispatch opts. Note the constructor checks `maxSize < 1`, so the minimum is 1 byte.","commonSituations":"Setting `dumpMaxSize: 0` intending 'don't dump' (it errors instead); reading the cap from env as a string; passing a human-readable size. The interceptor's `createDumpInterceptor` reads `opts.dumpMaxSize`, so the validation surfaces when you dispatch with an invalid per-request override.","solutions":["Pass a finite integer ≥1, e.g. `maxSize: 4 * 1024 * 1024` for 4 MiB.","If loading from config/env, coerce with `Number(...)` and check `Number.isFinite(v) && v >= 1`.","To use the default, omit the option entirely (1 MiB default applies)."],"exampleFix":"// before\nnew DumpHandler({ maxSize: 0 }, handler)\ndispatch({ ..., dumpMaxSize: process.env.DUMP_SIZE })\n\n// after\nnew DumpHandler({ maxSize: 2 * 1024 * 1024 }, handler)\ndispatch({ ..., dumpMaxSize: Number(process.env.DUMP_SIZE) })","handlingStrategy":"validation","validationCode":"function validateMaxSize(v) {\n  if (v == null) return undefined\n  const n = Number(v)\n  if (!Number.isFinite(n) || n < 1) {\n    throw new Error('maxSize must be a finite number >= 1')\n  }\n  return n\n}","typeGuard":"function isValidMaxSize(v) {\n  return typeof v === 'number' && Number.isFinite(v) && v >= 1\n}","tryCatchPattern":null,"preventionTips":["Never pass 0 to 'disable' dumping.","Coerce env-derived sizes with Number() and parse units."],"tags":["undici","interceptor","dump","memory","validation","config"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}