Debugging story

Fixing a Chrome-only Supabase auth lock

A Nuxt and Supabase app kept freezing on login and session refresh, but only in Chrome. The cause was the lock Supabase Auth uses to coordinate token refreshes, and the fix was a targeted patch to the library itself.

Role
Frontend developer
Type
Client bug fix
Browser
Chrome only
Time to fix
Under an hour

Symptoms

Users would get stuck on a loading screen after signing in or when coming back to an open tab. Session calls simply never returned. A reload sometimes helped, other browsers were fine, and the problem had been around for a long time.

Root cause

Supabase Auth serializes session reads and token refreshes with a browser lock (the Navigator LockManager), so several tabs never refresh the same token at once. In Chrome, when a tab was throttled or put in the background in the middle of a refresh, that lock could stay held. Every auth call after that waited in line behind it, so the whole app hung.

The library had no reliable way to recover from a lock that was never released, so a configuration change was not enough.

The fix

  • Patched the auth library at the node_modules level so acquiring the lock has a timeout and a safe fallback, which means a stuck lock can no longer block authentication
  • Kept the patch small and documented, and applied it automatically on every install with patch-package, so it survives updates and is easy to remove once the upstream library handles it
  • Verified it in Chrome with multiple tabs, sleep and wake, and slow network conditions

Outcome

The freeze was gone, without downgrading packages or rewriting the auth flow. Diagnosis and fix took less than an hour.

“This was not a beginner bug, and Mateja handled it with real senior-level expertise.”
Upwork client · 5.0 review