Skip to main content
Your Lovable, Bolt or hand-written Supabase app has an Edge Function that fetches a video from a link and saves it to Storage. It works for a small test file, then fails on a real video with one of these:
  • A 546 with that body, and Memory limit exceeded or CPU Time exceeded in the function’s Logs tab.
  • A 504 Gateway Timeout when the function hasn’t responded after 150 seconds.
  • The function stops part-way through a long download or upload, because it reached its wall-clock limit.
This page explains which limit you hit, the fixes that cost nothing, and where they stop.

The limits a video runs into

From Supabase’s Edge Functions limits page, checked November 27, 2026: Supabase Storage adds its own cap: on the Free plan a single file can be at most 50 MB, and paid plans can raise it to 500 GB (file limits). A 10-minute 720p video is about 77 MB.

Why a video triggers a 546

The usual generated code reads the whole file into memory before uploading it:
Anything near 256 MB, or less once the upload copies the data again, ends the worker with a 546. We reproduced this on a test project: buffering a 1 GB file returned exactly the 546 body above. Supabase’s 546 guide also notes that a worker shuts down after it finishes a request once it has used half of its memory or CPU. If the link points straight at a file (an .mp4 on a CDN or in another bucket), pass the response body through instead of buffering it. The file then flows from the source to Storage in pieces:
supabase/functions/save-file/index.ts
We tested this on a Supabase Free project: a 30 MB MP4 streamed into a private bucket in under 2 seconds. Two more things help with long transfers:
  • To answer first and keep working, EdgeRuntime.waitUntil(promise) lets the function return a response straight away and finish the upload as a background task, so the caller doesn’t sit through the 150-second idle timeout. The wall-clock limit still applies to the background task.
  • For big files, Supabase recommends its TUS resumable upload endpoint for files over 6 MB, which also lets a failed upload continue where it stopped.

Where the free fixes stop

Streaming only works when you already have a URL that returns the file. That’s rarely what users paste:
  • A TikTok, YouTube, Instagram or X link is a web page, not a file, so fetch returns HTML. Getting the video out takes a downloader, and an Edge Function can’t run one: there’s no binary to run and no way to merge separate audio and video streams.
  • The same code often fails once deployed. Many sites block requests from cloud servers, so a download that works from your laptop gets an error or a bot check from Supabase’s servers. See Works locally, fails deployed.
  • Long videos run past the wall clock. Even a streamed transfer has to finish within 150 seconds on Free or 400 seconds on paid plans.

Let the file skip the function

With Importly, the Edge Function only sends the link. Importly downloads the video and puts the file in your own Supabase Storage bucket, then calls a webhook when it’s there. The function replies in about a second, so none of the limits above apply, and the file never passes through its memory.
The full, tested version (connecting the bucket once, the videos table, the signed webhook and playing files with signed URLs) is in Save videos to Supabase Storage. The Free plan’s 50 MB file cap still applies to what lands in your bucket, so use a lower videoQuality or audio only (includeVideo: false) for long videos on Free. For a transcript instead of the file, see Save transcripts to Supabase from an Edge Function.
A 10-minute 720p video costs about $0.15 to import, and maxCostDollars stops a long one before it’s charged. Try it free, no card required. See Pricing & credits.