AykutSarac/jsoncrack.com · info

Smart color scheme manager was unable to save color scheme.

Error message

Smart color scheme manager was unable to save color scheme.

What it means

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.

Source

Thrown at apps/www/src/lib/utils/mantineColorScheme.ts:62

          (window.localStorage.getItem(key) as MantineColorScheme) || defaultValue;
        return currentColorScheme;
      } catch {
        return defaultValue;
      }
    },

    set: value => {
      // Only store theme for dynamic paths
      if (!shouldUseDynamicBehavior()) return;

      // Update our in-memory value
      currentColorScheme = value;

      // Also save to localStorage
      try {
        window.localStorage.setItem(key, value);
      } catch (error) {
        console.warn("Smart color scheme manager was unable to save color scheme.", error);
      }
    },

    // These do nothing regardless of path
    subscribe: () => {},
    unsubscribe: () => {},
    clear: () => {
      currentColorScheme = null;
      if (typeof window !== "undefined") {
        window.localStorage.removeItem(key);
      }
    },
  };
}

View on GitHub (pinned to 3c9af69e23)

Solutions

  1. Catch is already present — this is non-fatal; the in-memory theme still works for the session.
  2. Free up origin localStorage (remove large unused keys) if QuotaExceededError recurs.
  3. Inform users in private-browsing modes that theme preference will not persist.
  4. Ensure cookies are enabled so Storage access is granted.

Example fix

// before
try {
  window.localStorage.setItem(key, value);
} catch (error) {
  console.warn("Smart color scheme manager was unable to save color scheme.", error);
}

// after — only warn on persistent quota errors, stay quiet on private-mode SecurityError
try {
  window.localStorage.setItem(key, value);
} catch (error) {
  if (error instanceof DOMException && error.name === "QuotaExceededError") {
    console.warn("Color scheme preference could not be saved: storage is full.", error);
  }
  // SecurityError (storage disabled) is expected in some private modes — stay silent.
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Probe localStorage writability once at startup
export function localStorageWritable(): boolean {
  try {
    const k = "__probe__";
    window.localStorage.setItem(k, "1");
    window.localStorage.removeItem(k);
    return true;
  } catch { return false; }
}

Type guard

// Distinguish quota vs disabled-storage
export function isQuotaError(error: unknown): error is DOMException {
  return error instanceof DOMException && error.name === "QuotaExceededError";
}

Try / catch

// Stay quiet on disabled storage; warn only on quota
try { window.localStorage.setItem(key, value); }
catch (error) {
  if (isQuotaError(error)) console.warn("Color scheme not saved: storage full.", error);
}

Prevention

When it happens

Trigger: 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.

Common situations: Safari private browsing; corporate browsers with strict cookie policies; a host origin whose localStorage is saturated; embedded context with storage partitioning.

Related errors


AI-assisted analysis of AykutSarac/jsoncrack.com@3c9af69e23 (2026-08-12). Data as JSON: /api/errors/949f1af059e299b2. Report an issue: GitHub.