• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / auth / 17277690859

27 Aug 2025 08:15PM UTC coverage: 70.588% (-0.2%) from 70.815%
17277690859

push

github

web-flow
feat: introduce request-scoped background tasks & async mail sending (#2126)

## Summary
Introduce a new `apitask` package for running background tasks within
the lifecycle of an API request. We then use this feature in the mailer
client to send emails in the background. Before the request returns to
the caller we first wait for all in-flight tasks to exit.

**Summary:**
* Define a `Task` interface for light background work.
* Add `Run(ctx, task)` to schedule tasks asynchronously when supported,
or fall back to synchronous execution otherwise.
* Add `Wait(ctx)` to block until all request-scoped tasks finish
* Add `Middleware` to wrap HTTP handlers, attaching a request-scoped
worker to the context and ensuring all tasks complete before returning a
response.
* Add a check for `EmailBackgroundSending` in mailer package, when
present wrap the mail client in a `backgroundMailClient`. When `Mail` is
called it will send a `mailer.Task` to `apitasks.Run` to send the email
in the background using the wrapped `MailClient`.
* Add config `GOTRUE_MAILER_EMAIL_BACKGROUND_SENDING` (def `false`) -
on/off switch.

I will follow up with unit tests once the team has had an opportunity to
review.

---------

Co-authored-by: Chris Stockton <chris.stockton@supabase.io>

55 of 116 new or added lines in 5 files covered. (47.41%)

66 existing lines in 3 files now uncovered.

12348 of 17493 relevant lines covered (70.59%)

69.65 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.39
/internal/api/api.go


Source Not Available

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc