🧭 Debugging a Web App That Only Works in Safari Private Mode

Silhouette di giraffe

Have you ever opened a site in Safari, only to find it mysteriously breaks in normal mode, but works perfectly in private browsing? That happened to me recently with a JavaScript-heavy web app — and here’s how I tracked it down and fixed it.


đŸ§© The Symptoms

  • Site wouldn’t load in regular Safari.
  • Same site worked just fine in private mode.
  • Safari’s Web Inspector Console showed cryptic errors like:
    • TypeError: undefined is not an object (evaluating ‘Hr[Qr][Ie]’)
    • Unhandled Promise Rejection: Error: No response received
    • 404 Not Found on /manifest.json

🔍 Investigation with Safari Web Inspector

In the Console, the JavaScript error pointed to a chunk of code inside a minified file like main.4e230b2a.js. That meant something in the app was failing very early — before rendering anything.

Switching over to the Sources tab, I found this line in the HTML:

<script>
  const log = localStorage.getItem("log")
</script>

That line itself wasn’t failing, but it hinted the app was using localStorage heavily — and likely relying on specific stored values to boot correctly.


💡 The Key Insight

Because the site worked in private mode, that meant the problem was almost certainly tied to something stored in localStorage or cookies. Private mode doesn’t persist localStorage or cookies between sessions, so it gave us a clean slate.


✅ The Fix: Clear LocalStorage

To confirm the theory, I opened the site in normal Safari, opened Web Inspector > Console, and ran:

localStorage.clear();

Then refreshed the page — and boom, the site loaded perfectly again.


🔐 Bonus: Safer Alternatives

If you don’t want to clear everything, you can target just the problem key:

localStorage.removeItem("log");

Or inspect what’s in storage:

console.log(localStorage);

📌 Takeaway

If a web app works in private mode but not normal mode, always suspect:

  • Corrupt or stale data in localStorage
  • Cookies that don’t match current server state
  • Extensions blocking or injecting scripts
  • Cache mismatch between frontend and backend

Safari’s developer tools can help you trace it — even though they’re a bit hidden compared to Chrome’s.


Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.