{"record":{"id":"8b3ddec7803a3a14","repo":"nodejs/node","slug":"sqlitecachestore-options-maxentrysize-must-be-a-no","errorCode":null,"errorMessage":"SqliteCacheStore options.maxEntrySize must be a non-negative integer","messagePattern":"SqliteCacheStore options\\.maxEntrySize must be a non-negative integer","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"deps/undici/src/lib/cache/sqlite-cache-store.js","lineNumber":90,"sourceCode":"   */\n  #deleteOldValuesQuery\n\n  /**\n   * @param {import('../../types/cache-interceptor.d.ts').default.SqliteCacheStoreOpts | undefined} opts\n   */\n  constructor (opts) {\n    if (opts) {\n      if (typeof opts !== 'object') {\n        throw new TypeError('SqliteCacheStore options must be an object')\n      }\n\n      if (opts.maxEntrySize !== undefined) {\n        if (\n          typeof opts.maxEntrySize !== 'number' ||\n          !Number.isInteger(opts.maxEntrySize) ||\n          opts.maxEntrySize < 0\n        ) {\n          throw new TypeError('SqliteCacheStore options.maxEntrySize must be a non-negative integer')\n        }\n\n        if (opts.maxEntrySize > MAX_ENTRY_SIZE) {\n          throw new TypeError('SqliteCacheStore options.maxEntrySize must be less than 2gb')\n        }\n\n        this.#maxEntrySize = opts.maxEntrySize\n      }\n\n      if (opts.maxCount !== undefined) {\n        if (\n          typeof opts.maxCount !== 'number' ||\n          !Number.isInteger(opts.maxCount) ||\n          opts.maxCount < 0\n        ) {\n          throw new TypeError('SqliteCacheStore options.maxCount must be a non-negative integer')\n        }\n        this.#maxCount = opts.maxCount","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/undici/src/lib/cache/sqlite-cache-store.js#L72-L108","documentation":"Thrown when opts.maxEntrySize is defined but is not a safe non-negative integer. The guard requires typeof === 'number', Number.isInteger(...) true, and value >= 0; failing any one throws. maxEntrySize bounds the size of a single cached response body in bytes.","triggerScenarios":"Passing maxEntrySize as a float (1.5e6), a string ('1000'), a negative number, NaN, or Infinity. Also triggers with BigInt since typeof BigInt is 'bigint' not 'number'.","commonSituations":"Reading size from env vars as a string and forgetting to convert; mixing units (passing KB instead of bytes); using a decimal because 1.5 MB was the intent.","solutions":["Pass an integer byte count: new SqliteCacheStore({ maxEntrySize: 1024 * 1024 }).","If reading from config, coerce explicitly: Number.parseInt(process.env.MAX_ENTRY, 10).","Omit maxEntrySize entirely to accept the default cap.","Double-check you are not passing KB/MB units — the value is raw bytes."],"exampleFix":"// before\nnew SqliteCacheStore({ maxEntrySize: '1MB' })\n// after\nnew SqliteCacheStore({ maxEntrySize: 1024 * 1024 })","handlingStrategy":"validation","validationCode":"function coerceMaxEntrySize(v) {\n  const n = Number(v)\n  if (!Number.isInteger(n) || n < 0) {\n    throw new TypeError('maxEntrySize must be a non-negative integer (bytes)')\n  }\n  return n\n}","typeGuard":"function isValidMaxEntrySize(v) {\n  return typeof v === 'number' && Number.isInteger(v) && v >= 0\n}","tryCatchPattern":null,"preventionTips":["Always parse env/config values with Number.parseInt(..., 10).","Remember the unit is bytes, not KB/MB.","Omit the option when you want the default.","Add a unit-test that feeds strings and floats."],"tags":["cache","sqlite","validation","numeric","undici"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}