Insights / October 24, 2026

Supabase edge function limits: fixing 546 WORKER_RESOURCE_LIMIT

A 546 response with WORKER_RESOURCE_LIMIT means your Supabase edge function ran out of memory or CPU time, and Supabase stopped it mid-request. The usual cause is a function that holds whole files or large datasets in memory: it works on small test data and fails on real customer data. Streaming and paging fix some cases. Work that grows with your customers’ data belongs somewhere built for it.

What 546 WORKER_RESOURCE_LIMIT means

Edge functions run in small, short-lived sandboxes called isolates. Each one gets a fixed budget of memory and CPU. When a request uses up that budget, the isolate is killed and the caller gets this:

{
  "code": "WORKER_RESOURCE_LIMIT",
  "message": "Function failed due to not having enough compute resources (please check logs)"
}

The same error used to be called WORKER_LIMIT. The function’s Logs tab in the Supabase dashboard tells you which budget ran out: Memory limit exceeded or CPU Time exceeded. Supabase’s 546 troubleshooting guide covers both.

The common causes:

  • Buffering whole files. Calling arrayBuffer() or blob() on a download, or building a ZIP, PDF or image entirely in memory.
  • Loading big query results into one array instead of working in pages.
  • CPU-heavy work such as resizing images, hashing large payloads or deep recursion.

CPU time only counts actual computing, not time spent waiting on the network. A function that mostly downloads and uploads rarely hits the CPU limit. Memory is the one that usually gets you.

Supabase edge function limits

These are the runtime limits on Supabase’s hosted platform, from the official limits page. Lovable Cloud runs on Supabase, and Lovable apps hit the same 546 errors.

Limit Value What happens when you hit it
Memory 256 MB 546, log says Memory limit exceeded
CPU time per request 2 seconds, not counting time waiting on I/O 546, log says CPU Time exceeded
Wall clock (how long a worker stays alive) 150 s on Free, 400 s on paid plans Worker shuts down
Request idle timeout 150 s to start sending a response 504 Gateway Timeout
Functions calling functions 30 calls per chain, within 60 s The next call throws a RateLimitError

Four things catch people out:

  • Memory and CPU are the same on every plan. Upgrading raises the wall clock, not the memory. You can’t pay your way out of a 546.
  • There’s no published request or response size cap. In practice, memory is the ceiling if you buffer the data, and the wall clock is the ceiling if you stream it.
  • An isolate that passes 50% of any budget finishes its current request and then shuts down. If that request uses up the rest, you get a 546. This is why the error can look random under load.
  • Supabase’s docs give two memory numbers. The limits page says 256 MB; the 546 troubleshooting page says 250 MB. Budget for 250.

There are deployment limits too: up to 100 functions per project on Free, 1,000 on Pro and 2,000 on Team.

Why it works in testing and fails in production

A function that buffers data uses memory in proportion to the data. With five test files it peaks at a few megabytes. With a real customer’s data it can pass 256 MB on the same code path. Nothing changed except the input size, so nothing fails until a real user with real data hits it.

A size cap doesn’t solve this either. It just moves the point where it breaks, as the case below shows.

A real case: ZIP downloads in a media delivery app

We look after a media delivery app where clients download whole galleries of photos and video as a ZIP. Big galleries already went to a queue and were built by a separate service. Small ones had a “fast path”: if a full gallery had up to 200 files and up to 250 MB, the edge function that started the download called a second edge function, which built the whole ZIP inline while the first one waited.

In production the fast path failed on a 20-file, 151 MB gallery, twice. Calling the ZIP function directly returned 546 WORKER_RESOURCE_LIMIT. The function that called it then returned a 500 after about a minute and created no download job, so the visitor just saw an error.

The code explained it. The ZIP function’s header comment said it used a “chunked/streaming approach to handle large galleries without memory overflow”. The code did the opposite:

  1. It downloaded each source file completely into memory.
  2. It added each one to a ZIP being assembled in memory.
  3. When finished, it copied the whole archive into a second buffer before uploading it.

That’s at least two full copies of the archive at the end: over 300 MB for a 151 MB gallery, in a 256 MB sandbox.

The size cap had already been lowered once. An inline comment recorded a 42-file, 766 MB gallery crashing with the same 546 when the cap was 800 MB, so it was cut to 250 MB. That only moved the failure point. Two more problems made it worse:

  • The cap counted only files that had finished processing, but the ZIP function zipped every file in the gallery. A gallery still mid-upload passed the check and then blew the memory limit.
  • Even a successful inline build wasn’t saved as a download job. The download page reads from those job records, so visitors saw “ready” and got nothing.

What we changed

We removed the fast path entirely. Every uncached gallery ZIP now goes through the same queue that large galleries already used.

  • The edge function only coordinates. It checks permissions, rate limits and the cache, creates a job record, hands the job to the ZIP service, and returns queued straight away.
  • The ZIP service does the heavy lifting. It’s a small Python container service on Fly.io. It reads source files in 8 MB chunks, writes the ZIP as it goes, and uploads it to object storage in 64 MB parts. Memory use depends on the chunk and part sizes, not the gallery size, and there’s no time limit on a job.
  • The page polls for progress every 15 seconds while a build runs, instead of holding a request open.
  • The finished ZIP downloads straight from storage through a signed link, which is a temporary URL that expires, and it’s cached for 7 days so a second request is instant.

Galleries of three files or fewer skip the ZIP and download the files directly. Every other download now creates a job record before any work starts, so a failure shows up as a failed job that can be retried, not a blank 500.

The pattern: keep edge functions thin

Edge functions are good at short, light work: checking who’s asking, reading a few rows, signing a URL, calling an API. Anything that grows with the size of a customer’s data, and can’t be streamed or paged, belongs elsewhere.

  • Queue and worker. Write a job row, let a long-running service process it, and have the page poll or listen for the result. A container service, a background worker or a database queue all work.
  • Storage-direct transfers. Hand the browser a signed URL for uploads and downloads. Never pass user files through a function: it costs memory, wall clock and, on usage-billed platforms, network charges. The same applies to large video uploads.
  • Stream when you must touch the bytes. Pass a ReadableStream through instead of calling arrayBuffer(). That fixes memory, but the 400-second wall clock still applies.
  • Don’t chain functions that wait on each other. The caller sits idle using up its own wall clock, and one failure takes both down.

How to find out if your functions are close to the limits

  1. Search your logs for status 546 and 504, and for Memory limit exceeded, CPU Time exceeded and the shutdown reason WallClockTime. Supabase’s guide includes SQL queries that join function logs to 546 responses.
  2. Open each function’s Metrics tab and look at peak memory and execution time, not the average. A function that peaks near 256 MB on today’s biggest customer is one larger customer away from failing.
  3. Search your function code for arrayBuffer(), .blob(), BlobWriter, ZIP or PDF libraries, and queries without a limit or range. Don’t trust comments that say the code streams. Check.
  4. Test with production-sized data. Run each heavy function against your largest real customer’s data, then twice that. Test data is almost always too small to find this.
  5. Check what callers do when a function fails. If a 546 leaves no record and no retry, users get a dead end and you get no signal.

If your app’s server functions are failing on real data, a vibe coding rescue starts by finding which ones are near their limits and moving the heavy work to where it belongs.

LET’S TALK.

Book a free 30-minute call with Virgil

Pick a time that suits you. You’ll get a straight answer on what you need, what it should cost and the fastest path to launch.

Loading available times…

Open the calendar in a new tab

Send us your project

Virgil replies personally within one business day.

Book a free strategy call