{"record":{"id":"2ef8b7b1bd0f749a","repo":"diegosouzapw/OmniRoute","slug":"hot-reload-failed-to-apply-runtime-settings-afte","errorCode":null,"errorMessage":"[HOT_RELOAD] Failed to apply runtime settings after update:","messagePattern":"\\[HOT_RELOAD\\] Failed to apply runtime settings after update:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/lib/db/settings.ts","lineNumber":341,"sourceCode":"    insert.run(SETTINGS_REVISION_KEY, JSON.stringify(currentRevision + 1));\n  });\n  tx();\n  backupDbFile(\"pre-write\");\n  invalidateDbCache(\"settings\"); // Bust the read cache immediately\n\n  // Bust proxy resolution cache when proxy toggle settings change\n  const PROXY_TOGGLE_KEYS = [\"proxyEnabled\", \"perKeyProxyEnabled\"];\n  if (Object.keys(updates).some((k) => PROXY_TOGGLE_KEYS.includes(k))) {\n    bumpProxyConfigGeneration();\n  }\n\n  const nextSettings = await getSettings();\n\n  try {\n    const { applyRuntimeSettings } = await import(\"@/lib/config/runtimeSettings\");\n    await applyRuntimeSettings(nextSettings, { source: \"settings:update\" });\n  } catch (error) {\n    console.warn(\n      \"[HOT_RELOAD] Failed to apply runtime settings after update:\",\n      error instanceof Error ? error.message : error\n    );\n  }\n\n  // Onboarding / setup finished → one-shot Codex catalog revalidation (init case).\n  if (setupJustCompleted) {\n    void import(\"@/shared/services/codexCatalogRevalidation\")\n      .then(({ scheduleCodexCatalogRevalidationAfterInit }) => {\n        scheduleCodexCatalogRevalidationAfterInit();\n      })\n      .catch(() => {\n        // non-fatal\n      });\n  }\n\n  return nextSettings;\n}","sourceCodeStart":323,"sourceCodeEnd":359,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/db/settings.ts#L323-L359","documentation":"After settings were persisted and the settings revision bumped, applying the new runtime settings via applyRuntimeSettings (hot reload) threw. The DB now holds the new values but the running process still operates on the old runtime configuration until a later hot-reload check or restart applies them.","triggerScenarios":"Thrown at src/lib/db/settings.ts:341 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the logged error to find the setting that failed to apply","Trigger another settings save or wait for the next hot-reload poll","Restart the server to force a full settings reload if inconsistent"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}