{"record":{"id":"949f1af059e299b2","repo":"AykutSarac/jsoncrack.com","slug":"smart-color-scheme-manager-was-unable-to-save-colo","errorCode":null,"errorMessage":"Smart color scheme manager was unable to save color scheme.","messagePattern":"Smart color scheme manager was unable to save color scheme\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"apps/www/src/lib/utils/mantineColorScheme.ts","lineNumber":62,"sourceCode":"          (window.localStorage.getItem(key) as MantineColorScheme) || defaultValue;\n        return currentColorScheme;\n      } catch {\n        return defaultValue;\n      }\n    },\n\n    set: value => {\n      // Only store theme for dynamic paths\n      if (!shouldUseDynamicBehavior()) return;\n\n      // Update our in-memory value\n      currentColorScheme = value;\n\n      // Also save to localStorage\n      try {\n        window.localStorage.setItem(key, value);\n      } catch (error) {\n        console.warn(\"Smart color scheme manager was unable to save color scheme.\", error);\n      }\n    },\n\n    // These do nothing regardless of path\n    subscribe: () => {},\n    unsubscribe: () => {},\n    clear: () => {\n      currentColorScheme = null;\n      if (typeof window !== \"undefined\") {\n        window.localStorage.removeItem(key);\n      }\n    },\n  };\n}\n","sourceCodeStart":44,"sourceCodeEnd":77,"githubUrl":"https://github.com/AykutSarac/jsoncrack.com/blob/3c9af69e23c635356293b6b28cf4cd0af10d1059/apps/www/src/lib/utils/mantineColorScheme.ts#L44-L77","documentation":"console.warn from the smart Mantine color scheme manager when window.localStorage.setItem(key, value) throws. localStorage can throw QuotaExceededError (storage full), SecurityError (storage disabled, e.g. cookies blocked), or a generic error in private browsing modes that disable storage. The in-memory currentColorScheme has already been updated, so the runtime theme is correct; only persistence is lost.","triggerScenarios":"Browser storage quota exceeded (many apps/sites sharing the origin); cookies/storage blocked by browser settings; Safari private mode throwing on setItem; a browser extension stripping storage access.","commonSituations":"Safari private browsing; corporate browsers with strict cookie policies; a host origin whose localStorage is saturated; embedded context with storage partitioning.","solutions":["Catch is already present — this is non-fatal; the in-memory theme still works for the session.","Free up origin localStorage (remove large unused keys) if QuotaExceededError recurs.","Inform users in private-browsing modes that theme preference will not persist.","Ensure cookies are enabled so Storage access is granted."],"exampleFix":"// before\ntry {\n  window.localStorage.setItem(key, value);\n} catch (error) {\n  console.warn(\"Smart color scheme manager was unable to save color scheme.\", error);\n}\n\n// after — only warn on persistent quota errors, stay quiet on private-mode SecurityError\ntry {\n  window.localStorage.setItem(key, value);\n} catch (error) {\n  if (error instanceof DOMException && error.name === \"QuotaExceededError\") {\n    console.warn(\"Color scheme preference could not be saved: storage is full.\", error);\n  }\n  // SecurityError (storage disabled) is expected in some private modes — stay silent.\n}","handlingStrategy":"try-catch","validationCode":"// Probe localStorage writability once at startup\nexport function localStorageWritable(): boolean {\n  try {\n    const k = \"__probe__\";\n    window.localStorage.setItem(k, \"1\");\n    window.localStorage.removeItem(k);\n    return true;\n  } catch { return false; }\n}","typeGuard":"// Distinguish quota vs disabled-storage\nexport function isQuotaError(error: unknown): error is DOMException {\n  return error instanceof DOMException && error.name === \"QuotaExceededError\";\n}","tryCatchPattern":"// Stay quiet on disabled storage; warn only on quota\ntry { window.localStorage.setItem(key, value); }\ncatch (error) {\n  if (isQuotaError(error)) console.warn(\"Color scheme not saved: storage full.\", error);\n}","preventionTips":["Treat setItem failures as non-fatal — the in-memory theme is already set.","Free origin localStorage if QuotaExceededError recurs.","Expect SecurityError in private-browsing modes and degrade silently."],"tags":["localstorage","theme","mantine","browser","quotas","non-fatal"],"backgroundTag":null,"analyzedSha":"3c9af69e23c635356293b6b28cf4cd0af10d1059","analyzedAt":"2026-08-12T19:00:27.891Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}