Short answer
Your function ran but returned an error status (4xx or 5xx). In supabase-js that is a FunctionsHttpError, and the function’s own error message is in error.context: read it with await error.context.json(). Then check the function’s logs in the Logs tab of the Supabase dashboard, fix what the function reports, and have it return a clear status code and message.
How to find the real error
01
The real error is in error.context
“FunctionsHttpError: Your function executed but returned an error (4xx/5xx status)” Supabase, Edge Functions: Error handling
Check which kind of error you got, and for a FunctionsHttpError, read the body the function sent back. This is Supabase’s example:
import { FunctionsFetchError, FunctionsHttpError, FunctionsRelayError } from '@supabase/supabase-js' const { data, error } = await supabase.functions.invoke('hello', { headers: { 'my-custom-header': 'my-custom-header-value' }, body: { foo: 'bar' }, }) if (error instanceof FunctionsHttpError) { const errorMessage = await error.context.json() console.log('Function returned an error', errorMessage) } else if (error instanceof FunctionsRelayError) { console.log('Relay error:', error.message) } else if (error instanceof FunctionsFetchError) { console.log('Fetch error:', error.message) }02
The function’s logs say what failed
“You can see the production error logs in the Logs tab of your Supabase Dashboard.” Supabase, Edge Functions: Error handling
Open the function in the dashboard and read its logs around the time of the failed call. Errors the function logs with console.error appear there; if it logs nothing, add logging around the step that fails.
03
Every problem comes back as a 500
“Return 400 for bad user input, 404 when something doesn't exist, 500 for server errors, etc.” Supabase, Edge Functions: Error handling
If the function returns 500 for everything, the app can’t tell a bad form value from a crash. Return the right status with a JSON body that carries a message, so the app can show people something useful.
04
A relay or fetch error is a different problem
“FunctionsFetchError: Function couldn't be reached at all” Supabase, Edge Functions: Error handling
If the error is a FunctionsRelayError or FunctionsFetchError instead, the function didn’t answer with its own error. We check the function name, that it is deployed, and the network before touching the function’s code.
Checked against the vendor’s docs on : Supabase docs: Edge Functions error handling.
Rather hand it over?
Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.
- from $450App Fix TicketOne reproducible bug in an existing mobile or web app, diagnosed and fixed.See scope and start
- from $450AI-Built App RescueA Lovable, Bolt or Cursor app checked end to end in 3 days, then its worst problems fixed at a fixed price.No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way.See scope and start
Related: Supabase Edge Function CORS error · Supabase Edge Function timeout · Lovable Edge Function secret missing · Supabase public storage bucket