Skip to content

auth-js: GoTrueClient logs raw console.error when session recovery is aborted by page navigation #2543

Description

@Primiasolutions

Bug report

Package: @supabase/auth-js 2.110.2 (checked the shipped dist up to 2.110.7 — same behavior)
Environment: Browser (Next.js 15 app using @supabase/ssr browser client)

What happens

When a full page load kicks off GoTrueClient's session recovery and the user navigates away before it settles, the in-flight auth request (GET /auth/v1/user) is aborted by the browser (net::ERR_ABORTED), the fetch rejects with TypeError: Failed to fetch, and GoTrueClient logs it raw via console.error(err):

TypeError: Failed to fetch
    at <chunk>.js:46:3806   ← auth-js fetch helper
    ...

Two catch blocks do this with no abort handling:

  • the INITIAL_SESSION emission wrapper — catch (err) { ... isAuthSessionMissingError(err) ? console.warn(err) : console.error(err) }
  • _recoverAndRefresh's outer catch (err) { ... console.error(err); return; }

Repro (deterministic)

Any flow that navigates immediately after a page load, e.g. Playwright:

await page.goto(`${BASE}/login`);
// ...fill credentials, submit...
await page.waitForURL(`${BASE}/`);
await page.goto(`${BASE}/some-other-page`); // aborts the fresh page's auth init

page.on("requestfailed") shows net::ERR_ABORTED GET https://<ref>.supabase.co/auth/v1/user, followed by the raw TypeError: Failed to fetch console error. It does not reproduce on slow dev servers (the fetch settles before the navigation), which is why it mostly shows up in production E2E.

Why it matters

The user did nothing wrong and the app is fine — the page was simply superseded. But the raw console.error pollutes production consoles and breaks strict zero-console-error E2E gates (we had a smoke suite flaking on exactly this, hopping between test cases depending on which fetch was in flight).

Expected

Abort-caused network failures during a superseded page load shouldn't surface as raw console.error. Options: detect AbortError/failed-fetch on a page that's unloading and downgrade to console.warn/debug, or route these through the existing _debug channel like other transient conditions (the auto-refresh tick already labels its failures as "likely a transient error").

Happy to provide more traces if useful.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions