© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•7d ago•
2 replies
Despair

How to prevent Supabase JS from logging / duplicating AuthApiError and let the caller handle it?

Solved🟡javascript
When I run this code:

try {
  const { data: authData, error: authError } =
    await supabaseClient.auth.getUser();

  if (authError) {
    logger.error({ authError }, "Failed to get user");
    return;
  }

  if (!authData.user) {
    logger.error("Unauthorized");
    return;
  }
} catch (error) {
  logger.error({ error }, "Failed to get user");
  return;
}
try {
  const { data: authData, error: authError } =
    await supabaseClient.auth.getUser();

  if (authError) {
    logger.error({ authError }, "Failed to get user");
    return;
  }

  if (!authData.user) {
    logger.error("Unauthorized");
    return;
  }
} catch (error) {
  logger.error({ error }, "Failed to get user");
  return;
}


I expect exactly one log (the one I emit).
However, when the auth state is invalid, Supabase JS prints its own stack trace twice before my handler runs:

[check file]

This happens even though:

* the error is returned to me (not thrown),
* I explicitly handle it,
* and my process does not crash.

I’m not asking how to fix
refresh_token_not_found
refresh_token_not_found
, this error is expected in my case.

My question is:

* How do I stop
@supabase/supabase-js
@supabase/supabase-js
from logging / throwing internally?
* Is there a config option to disable internal error logging / background refresh attempts?
* Is there a way to make Supabase JS behave like a “silent” auth check and let the caller fully own logging and control flow?
supabase.log3.07KB
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

AuthApiError using supabase-js from node
SupabaseSSupabase / help-and-questions
4y ago
How to investigate AuthApiError
SupabaseSSupabase / help-and-questions
4y ago
Is it possible to stop Supabase from logging so much?
SupabaseSSupabase / help-and-questions
4y ago
mapping from supabase-js to REST
SupabaseSSupabase / help-and-questions
4y ago