-
Notifications
You must be signed in to change notification settings - Fork 1
Description
3923976 and a few earlier commits introduced styled emails for:
- Auth actions (like signing up, changing email address)
- New chat messages
I made a custom hook for auth actions called send-email-for-auth-action. It's very similar to the official example for Supabase.
Very occasionally, user sign up (email_action_type === "signup") fails with a 422/500 error:
422: Failed to reach hook within maximum time of 5.000000 seconds
This is returned to the user as a server error message on the sign up form, like this:
On the Supabase side, I see the following:
The user who failed sign up still receives the sign up email (via Resend) but the verification link inside that email doesn't work (as you would expect, since sign up didn't properly complete).
Details
The Supabase auth hooks documentation says:
Outside of runtime errors, both HTTP Hooks and Postgres Hooks return timeout errors. Postgres Hooks have 2 seconds to complete processing while HTTP Hooks should complete in 5 seconds. Both HTTP Hooks and Postgres Hooks are run in a transaction do limit the duration of execution to avoid delays in authentication process.
So, for some reason, and only very occasionally, sign ups seem to take longer than five seconds. I suppose that checks out when I look at the average execution time for that edge function:
What isn't clear to me is how to reduce the time this edge function takes. Here's how it's set up:
- The function is small (~50KB bundle)
- Boot time is always fast (200–500ms)
- The error only happens on email_action_type === "signup", and only sometimes, seemingly random
- The email is always sent, even when the error happens
- Timing logs show no single step is consistently slow
- The error is always a 5s timeout from Supabase’s side


