Skip to content

[Question]: How to handle rate limiting of SMTP #851

Open
@tschuehly

Description

@tschuehly

General info

  • I checked the troubleshooting page for similar problems

What is your question?

Supabase hard caps the smtp mail delivery to 1 per second:

Image

How should this be handled using the gotrue module?

I get the exception: Supabase failed: over_email_send_rate_limit with message: For security purposes, you can only request this after 0 seconds., code: OverEmailSendRateLimit

Relevant log output (optional)

Activity

self-assigned this
on Feb 9, 2025
jan-tennert

jan-tennert commented on Feb 9, 2025

@jan-tennert
Collaborator

You can check for the OverEmailSendRateLimit AuthErrorCode:

try {
    supabase.auth.signUpWith(Email)
} catch(e: AuthRestException) {
    when(e.errorCode) {
        AuthErrorCode.OverEmailSendRateLimit -> {
            // Handle the error
        }
        else -> {
            // Other error codes
        }
    }
}

The generic RestException subclasses were superseded by the AuthRestExceptions:

* @throws RestException or one of its subclasses if receiving an error response. If the error response contains a error code, an [AuthRestException] will be thrown which can be used to easier identify the problem.

tschuehly

tschuehly commented on Feb 10, 2025

@tschuehly
Author

Hey @jan-tennert,

I already have an Exception Handler, but I would have to handle the retry mechanism manually in a generic way.

https://github.com/tschuehly/htmx-supabase-spring-boot-starter/blob/master/src%2Fmain%2Fkotlin%2Fde%2Ftschuehly%2Fhtmx%2Fspring%2Fsupabase%2Fauth%2Fservice%2FSupabaseUserService.kt#L249

I think it could be a good idea to maybe introduce a queue or something similar?

jan-tennert

jan-tennert commented on Feb 10, 2025

@jan-tennert
Collaborator

Do you mean generally in this repo or implementation wise?
For a web server, wouldn't it be better to redirect the error to the client for it to handle, since the interval could be longer than a second?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

    Participants

    @jan-tennert@tschuehly

    Issue actions

      [Question]: How to handle rate limiting of SMTP · Issue #851 · supabase-community/supabase-kt