© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•13mo ago•
65 replies
Az3K

Edge Functions & JWT Claims Auth Hook timeouts

Hello, I'm currently implementing an edge functions which is being called as an auth hook to get custom claims.

The code is working fine currently, but I would like to also update the user/app metadata in the supabase db for the users and when I try to call the supabase auth admin to update the user by id, it always timeouts, the logs shows that the hook took more than 5 seconds every single time I try to update and it's impossible to have great error handling, as the edge function is being called, logs are showing up to the supabase auth admin call, then timeouts so I have no idea why it can timeout.

In the Auth log in supabase dashboard, I always get :
422: Failed to reach hook within maximum time of 5.000000 seconds
422: Failed to reach hook within maximum time of 5.000000 seconds


And in the Postgres logs I get:
process 65551 acquired ShareLock on transaction 1346 after 2707.894 ms
process 65551 acquired ShareLock on transaction 1346 after 2707.894 ms

process 65551 still waiting for ShareLock on transaction 1346 after 1000.072 ms
process 65551 still waiting for ShareLock on transaction 1346 after 1000.072 ms

connection authorized: user=supabase_auth_admin database=postgres
connection authorized: user=supabase_auth_admin database=postgres

And they corresponds to the UPDATE query made my the updateUserById call.


Here is the code snippet:
Admin client
  const supabaseClient = createClient(
    Deno.env.get("SUPABASE_URL") ?? "",
    Deno.env.get("SUPABASE_SERVICE_ROLE_KEY") ?? "",
    {
      auth: {
        autoRefreshToken: false,
        persistSession: false
    }}
  );

...

const { data: user, error } = await supabaseClient.auth.admin.updateUserById(
  user_id,
  { app_metadata: { subscription: subscription } }
)
Admin client
  const supabaseClient = createClient(
    Deno.env.get("SUPABASE_URL") ?? "",
    Deno.env.get("SUPABASE_SERVICE_ROLE_KEY") ?? "",
    {
      auth: {
        autoRefreshToken: false,
        persistSession: false
    }}
  );

...

const { data: user, error } = await supabaseClient.auth.admin.updateUserById(
  user_id,
  { app_metadata: { subscription: subscription } }
)


Thank you.
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
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

[URGENT] Connection timeouts - app with auth/database/edge functions
SupabaseSSupabase / help-and-questions
5mo ago
Auth timeouts
SupabaseSSupabase / help-and-questions
4mo ago
How to verify JWT on Edge Functions
SupabaseSSupabase / help-and-questions
3y ago
Invalid JWT for edge functions invoking other edge functions after Restore of backup
SupabaseSSupabase / help-and-questions
3mo ago
Next page