{"record":{"id":"dec90cf0a1d3c4f2","repo":"diegosouzapw/OmniRoute","slug":"cache-size-change-did-not-take-effect-expected","errorCode":null,"errorMessage":"cache_size change did not take effect (expected ${targetCacheSize}, got ${newCacheSize})","messagePattern":"cache_size change did not take effect \\(expected (.+?), got (.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/lib/db/optimizationSettings.ts","lineNumber":165,"sourceCode":"\nexport function setCacheSizeForDb(db: SqliteDatabase, cacheSizeKb: number): void {\n  const normalizedCacheSizeKb = requireCacheSizeKb(cacheSizeKb);\n  const currentCacheSize = db.pragma(\"cache_size\", { simple: true }) as number;\n  const targetCacheSize = -normalizedCacheSizeKb;\n\n  if (currentCacheSize === targetCacheSize) {\n    console.log(`[DB] cache_size already set to ${normalizedCacheSizeKb}KB`);\n    return;\n  }\n\n  console.log(\n    `[DB] Changing cache_size from ${Math.abs(currentCacheSize)}KB to ${normalizedCacheSizeKb}KB`\n  );\n  db.pragma(`cache_size = ${targetCacheSize}`);\n\n  const newCacheSize = db.pragma(\"cache_size\", { simple: true }) as number;\n  if (newCacheSize !== targetCacheSize) {\n    throw new Error(\n      `cache_size change did not take effect (expected ${targetCacheSize}, got ${newCacheSize})`\n    );\n  }\n  console.log(`[DB] cache_size changed to ${Math.abs(newCacheSize)}KB`);\n}\n\nfunction applyPersistentOptimizationPragmas(\n  db: SqliteDatabase,\n  settings: DatabaseOptimizationSettings\n): void {\n  const targetAutoVacuum = AUTO_VACUUM_MODE_TO_PRAGMA[settings.autoVacuumMode];\n  const targetPageSize = normalizePageSizeBytes(\n    settings.pageSize,\n    DEFAULT_DATABASE_SETTINGS.optimization.pageSize\n  );\n  const currentAutoVacuum = db.pragma(\"auto_vacuum\", { simple: true }) as number;\n  const currentPageSize = db.pragma(\"page_size\", { simple: true }) as number;\n","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/db/optimizationSettings.ts#L147-L183","documentation":"Error \"cache_size change did not take effect (expected ${targetCacheSize}, got ${newCacheSize})\" thrown in diegosouzapw/OmniRoute.","triggerScenarios":"Thrown at src/lib/db/optimizationSettings.ts:165 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","schemaVersion":2},"datasetVersion":"2026-08-25T21:54:21.419Z"}