Repository navigation
Description
Bug report
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
With custom templates set through GOTRUE_MAILER_TEMPLATES_* URLs and template reloading off (the default), one failed fetch on a cold cache makes Auth send the built-in template for the next GOTRUE_MAILER_TEMPLATE_MAX_AGE (10m), even when the template server is back a few seconds later.
GOTRUE_MAILER_TEMPLATE_RETRY_INTERVAL (10s) doesn't help in this case. It only applies once the cached entry is older than the max age. That works when a previously fetched custom template fails to refresh, but not when the only thing in the cache is the default fallback.
The background reloader (GOTRUE_MAILER_TEMPLATE_RELOADING_ENABLED=true) retries the fallback after the retry interval, so the two modes disagree. The CLI enables reloading, so local dev mostly doesn't hit this. The self-hosting compose file doesn't, so self-hosted setups do.
In practice: restart the stack, the first sign-up arrives before the template server is reachable (or it returns a 5xx or times out once), and every confirmation email for the next 10 minutes uses the default template. The only trace is a single templatemailer_template_body_http_error log line.
To Reproduce
- Run Auth with a custom template URL and the default reloading setting:
GOTRUE_MAILER_TEMPLATES_CONFIRMATION=http://templates-server/confirmation.html # GOTRUE_MAILER_TEMPLATE_RELOADING_ENABLED unset (false) - Stop the template server (or make it return 503).
- Sign up a user. The confirmation email uses the default template (expected, the server is down).
- Start the template server again.
- Wait 15 seconds and sign up another user.
- The email still uses the default template. Custom templates only come back after about 10 minutes from step 3.
Expected behavior
After the fallback, the configured template is retried after GOTRUE_MAILER_TEMPLATE_RETRY_INTERVAL, the same as with background reloading enabled. Once it loads, it's cached for the max age as usual.
System information
- Auth: master at 84ff0c0 (also in the
supabase/gotrue:v2.197.0image used by the self-hosting compose file) - Self-hosted, Docker Compose
Additional context
Related: #2153 (background template reloading) and #2783 (another way template fetches fail silently and fall back to the defaults).
Activity