Skip to content

Signing up sometimes fails #3

@dnywh

Description

@dnywh

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:

Image

On the Supabase side, I see the following:

Image

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:

Image

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions