{"record":{"id":"35b0a4298b995a7a","repo":"denoland/deno","slug":"err-invalid-arg-type-35b0a4","errorCode":"ERR_INVALID_ARG_TYPE","errorMessage":"ERR_INVALID_ARG_TYPE(\"historySize\", \"number\", historySize)","messagePattern":"ERR_INVALID_ARG_TYPE\\(\"historySize\", \"number\", historySize\\)","errorType":"validation","errorClass":"ERR_INVALID_ARG_TYPE","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/internal/readline/interface.mjs","lineNumber":239,"sourceCode":"    input = input.input;\n  }\n\n  if (completer !== undefined && typeof completer !== \"function\") {\n    throw new ERR_INVALID_ARG_VALUE(\"completer\", completer);\n  }\n\n  if (history === undefined) {\n    history = [];\n  } else {\n    validateArray(history, \"history\");\n  }\n\n  if (historySize === undefined) {\n    historySize = kHistorySize;\n  }\n\n  if (typeof historySize !== \"number\") {\n    throw new ERR_INVALID_ARG_TYPE(\"historySize\", \"number\", historySize);\n  }\n\n  if (NumberIsNaN(historySize) || historySize < 0) {\n    throw new ERR_OUT_OF_RANGE(\"historySize\", \">= 0\", historySize);\n  }\n\n  // Backwards compat; check the isTTY prop of the output stream\n  //  when `terminal` was not specified\n  if (terminal === undefined && !(output === null || output === undefined)) {\n    terminal = !!output.isTTY;\n  }\n\n  const self = this;\n\n  this.line = \"\";\n  this[kSubstringSearch] = null;\n  this.output = output;\n  this.input = input;","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/node/polyfills/internal/readline/interface.mjs#L221-L257","documentation":"options.historySize of readline.createInterface (the max number of retained history lines, default 30) must be a number when provided. A string, boolean, null, or object throws ERR_INVALID_ARG_TYPE('historySize', 'number'). undefined falls back to the default, and NaN numbers are handled by the separate range check that follows.","triggerScenarios":"createInterface({ historySize: '100' }) from parsed config/CLI args; historySize: parseInt(input) where parseInt returned NaN is caught here only if the argument was not a number type at all — strings are the common case; passing the whole options object as historySize.","commonSituations":"REPL tool configuration read from JSON/env where every value is a string; merging user preferences objects that carry stringified sizes.","solutions":["Convert numeric strings at the boundary: Number(options.historySize)","Validate config once: typeof cfg.historySize === 'number' or coerce and default","Omit the option to accept the default 30"],"exampleFix":"// before\ncreateInterface({ input, output, historySize: process.env.HIST_SIZE }); // string\n\n// after\ncreateInterface({ input, output, historySize: Number(process.env.HIST_SIZE) || 30 });","handlingStrategy":"type-guard","validationCode":"function readHistorySize(cfg: Record<string, unknown>): number | undefined {\n  const n = Number(cfg.historySize);\n  return Number.isFinite(n) && n >= 0 ? n : undefined;\n}\n\nreadline.createInterface({ input, output, historySize: readHistorySize(cfg) });","typeGuard":"const isHistorySize = (v: unknown): v is number =>\n  typeof v === 'number' && !Number.isNaN(v) && v >= 0;","tryCatchPattern":"try {\n  rl = readline.createInterface({ input, historySize: size as number });\n} catch (err) {\n  if (err?.code === 'ERR_INVALID_ARG_TYPE' && /historySize/.test(err.message)) {\n    rl = readline.createInterface({ input, historySize: Number(size) || 30 });\n  } else throw err;\n}","preventionTips":["Number()-convert historySize from env/JSON config at load time","Omit the option when the source is untrusted; default 30 applies"],"tags":["readline","node-compat","deno","argument-validation","history"],"backgroundTag":"invalid-argument-type","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-26T04:18:47.238Z"}