App Finishers

Fix guide · updated 2026-11-16

Edge Function 546 "not having enough compute resources" (WORKER_RESOURCE_LIMIT)

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

Your app calls a Supabase Edge Function and gets status 546 with "Function failed due to not having enough compute resources (please check logs)", code WORKER_RESOURCE_LIMIT. The function was stopped because it computed too long, used too much memory, or ran past its time limit. Older messages and the local server, supabase functions serve, use the code WORKER_LIMIT for the same thing. We reproduced each case with the Supabase CLI's local function server on Supabase's edge-runtime 1.79.1 and supabase-js 2.119, November 2026.

What your app sees

supabase-js doesn't show the 546 at first. functions.invoke() returns an error named FunctionsHttpError with the message "Edge Function returned a non-2xx status code". The status and the body are inside error.context:

const { data, error } = await supabase.functions.invoke('make-thumbnail', { body: { path } });
if (error?.context?.status === 546) {
  const body = await error.context.json().catch(() => null);
  console.log(body);
}

On Supabase's servers, body is {"code":"WORKER_RESOURCE_LIMIT","message":"Function failed due to not having enough compute resources (please check logs)"}. On your computer, the local server answers {"code":"WORKER_LIMIT","message":"Worker failed to respond due to a resource limit (please check logs)"}: we got exactly that for all three limits.

Supabase's servers also add an sb-error-code header with the code. The local server doesn't add it to a 546 (we checked its source and its answers), so test the status, not the header.

The three limits

Each call runs in a small worker with three limits. Going over one stops the function at once, and the caller gets the 546.

Separately, a call that hasn't started its answer after 150 seconds gets a 504 instead of a 546. You can't raise these limits on Supabase's servers.

Find which limit it was

In the Supabase dashboard, open the function, then its Logs tab, and look at the lines around the failed call:

Supabase's 546 article has log queries that list each 546 with its log line and show what share of calls fail.

The local server prints its own lines in the terminal: CPU time soft limit reached then CPU time hard limit reached, memory limit reached for the worker, or wall clock duration reached, each followed by "worker error WorkerRequestCancelled: request has been cancelled by supervisor".

Cause 1: too much computing in one call

Loops over many items, resizing images, reading PDFs or spreadsheets, encryption, big JSON transforms. In our test, a function that computed for 5 seconds was stopped after 2 seconds of CPU, and the caller got the 546 about 3 seconds after calling.

Spreading the work with await doesn't help, because CPU time adds up over the whole call. A function doing 10 seconds of computing in 20 ms slices, with an await between slices, was stopped after 2.7 seconds just the same.

Cause 2: too much memory

Loading a whole table, a large file or many images at once, or filling a big array in a loop. In our test, a function that kept 1 MB blocks in an array was stopped as it passed 256 MB, a fraction of a second after the call, before it could answer.

Cause 3: too long, waiting included

Waiting doesn't use CPU, so a slow AI model or API never causes a CPU stop. It runs into the time limits instead: no answer after 150 seconds gives the 504, and work still running when the worker's wall clock ends is cut off, with a 546 if the call was still waiting for it. A background task that keeps going after the answer is cut off the same way.

In our test, with the local server's wall clock set to 10 seconds, a function waiting 20 seconds for a timer used no CPU, was stopped at 10 seconds and answered 546. The local server has no 150-second 504: a slow call there ends as a 546 when its wall clock, 400 seconds by default, runs out.

Why it fails only sometimes

A worker isn't thrown away after one call. On Supabase's servers it serves the next calls to the same function, one at a time, and its CPU time adds up across them. Supabase's 546 article gives the rule: once a worker has used half of a limit, it finishes the call in progress and shuts down, and the next call gets a fresh worker. If that call uses up the rest first, the worker is stopped at once and the call gets the 546.

We reproduced this with edge-runtime itself, keeping workers like Supabase's servers do and with the local server's CPU settings (1 second to retire, 2 seconds to stop). Two calls with 0.3 seconds of computing each, then a call with 1.5 seconds on the same worker: that call was stopped. The same 1.5-second call on a fresh worker answered normally, and since it had used more than half, the next call went to a new worker. So a call that uses more than about 1 second of CPU passes on a fresh worker and fails on one that has already worked: the same input can pass in testing and fail for real users.

The local server can't show this, because it starts a new worker for every call: its main script passes forceCreate: true, and in our runs 8 calls in a row went to 8 different workers. It gives an early warning instead. When one call uses more than half the CPU budget, it prints CPU time soft limit reached even though the call succeeds. In our runs, every 1.5-second call printed it and none of the 0.3- or 0.8-second calls did. A call that prints it is the one to fix.

The local server's own surprise

Sometimes the local server answers a CPU or wall-clock stop with 503 and an empty body instead of the 546, and the terminal shows connection aborted (uri: "/your-function"). supabase-js then gives error.context.status 503, and error.context.json() fails on the empty body. It looks like a function that failed to start, but the CPU or wall-clock line just before it tells the real story. In our runs, 10 of 58 CPU and wall-clock stops came back that way, including the first CPU stop after every start of the server. All 12 memory stops gave the 546.

Fix 1: less computing per call

Fix 2: less memory at once

Fix 3: finish sooner

Fix 4: tell the user

A 546 shouldn't leave a blank screen or a spinner that never stops. Catch it and say something useful, and don't retry it in a loop: the same call with the same input usually fails the same way.

if (error?.context?.status === 546) {
  showError('This file is too big to process. Try a smaller one.');
}

If an AI tool built your app

Give your AI tool this prompt, with your function's name:

My Supabase Edge Function "make-thumbnail" fails with status 546 WORKER_RESOURCE_LIMIT ("Function failed due to not having enough compute resources"). The limits are 2 seconds of CPU per call, about 256 MB of memory, and 150 seconds (Free) or 400 seconds (paid) of wall clock. Read the function and list every place that computes a lot, holds a lot in memory, or waits a long time. Then change it so each call stays well under the limits: do filtering and sums in SQL or an rpc() function instead of loops, read rows in pages with range(), select only needed columns, send image or PDF work to an outside service, split big jobs into batches across several calls, run independent requests with Promise.all, and give outside requests a timeout with AbortSignal.timeout(). Splitting a loop with await does not reduce CPU time, so don't do that. In the app, catch error.context.status 546 and show a clear message instead of retrying. Show me each change before making it.

Not quite your error?

Still stuck?

Copy the request body of a failing call from your browser's Network tab, run the function locally with supabase functions serve, and send it that body. Watch the terminal for CPU time soft limit reached or a memory line. Then cut the input in half until the line goes away: that size is how much one call can safely do, and anything bigger needs splitting.

Other Supabase problems? See Supabase fixes.