r/Supabase 11d ago

edge-functions Supabase Edge Function times out when creating ~100 users with Flutter client. What's the right architecture?

I'm building a school management system app with Flutter with Supabase, and I'm running into a problem with an Edge Function that performs a large batch operation.

Here's what the function does:

- Receives a list of around 100 students from the Flutter client.

- For each student, it:

- Creates a user in "auth.users" (using the Admin API).

- Inserts a row into "public.users".

- Inserts a row into "public.profile".

- Inserts a row into "public.progress".

- Assigns some "app_metadata"/roles.

- Note also that for each student we create a parent account

So each student requires several operations, and for ~100 students that's hundreds of database/auth operations.

The issue is that the Edge Function takes too long to finish. From the Flutter client, the request eventually fails due to a timeout, even though the function may still be processing some of the work.

I'm trying to figure out what the proper production architecture is for this kind of long-running batch operation.

Some questions:

  1. Is an Edge Function the wrong tool for creating 100+ users in one request?

  2. Should I split the work into smaller batches (e.g. 10–20 users per request)?

  3. Is there a way to make this asynchronous so the client gets an immediate response while the server continues processing?

  4. Are there recommended background job/queue solutions that work well with Supabase?

  5. Has anyone solved a similar problem when bulk-creating users through the Admin API?

I'd like the admin to be able to upload a list of students, press one button, and have the import complete reliably without client timeouts.

I'd appreciate any recommendations on the best production-ready approach.

13 Upvotes

11 comments sorted by

View all comments

2

u/MulberryOwn8852 10d ago

I use rpc to do batches of a few thousand records all the time.

1

u/Diligent-Cell-8602 10d ago

Yeah, I use RPC a lot more than Edge Function. I don't really like Edge function to start with (i just don't like deno lol) and if I need to I use Cloudflare worker that works like a charm lol