edge-runtime: FunctionsFetchError: Failed to send a request to the Edge Function - effecting 1% of invocations

Bug report

  • [Uncertain] I confirm this is a bug with Supabase, not with my own application.
  • [x - threads I found on this same error did not help] I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

We are getting intermittent “Failed to send a request to the Edge Function” errors. This bug is quite hard to reproduce. I have never been able to reproduce it locally, and 98.5% of function invocations go through just fine. For context, we’ve seen this error 1.3k times out of 72,474 invocations. I’ve had users report that they are getting this error, but then when they retry it goes through fine the next time.

My big questions are:

  1. Is it normal to see this error intermittently in supabase edge runtime? Is this just a fact of life, is this a bug, or is something wrong on our end? It’s very hard to tell from my end.
  2. If it’s likely that something is wrong on our end, I’d love any suggestions of how to debug. The request body we send for this function is very simple (just a couple IDs and a text input) so there is not much variability. Having a hard time identifying a pattern especially since the error is not very descriptive.

The stack trace we see in sentry is this:

 // 2. client-level headers
                    // 3. default Content-Type header
                    headers: Object.assign(Object.assign(Object.assign({}, _headers), this.headers), headers),
                    body,
                }).catch((fetchError) => {
                    throw new FunctionsFetchError(fetchError);
                });
                const isRelayError = response.headers.get('x-relay-error');
                if (isRelayError && isRelayError === 'true') {
                    throw new FunctionsRelayError(response);
                }

To Reproduce

I can’t even reproduce this locally, so I can’t provide reproduction steps.

Additional Context

We are running supabase CLI 1.142.1 and "@supabase/supabase-js": "2.39.1",

Please let me know if there’s anything else I can provide that would be helpful.

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 3
  • Comments: 20 (6 by maintainers)

Most upvoted comments

@laktek, thanks for your response.

The biggest issue here is that the error codes don’t give any information on which one of the options you listed was the reason for the error.

From our perspective

  • Your client’s firewall blocking requests - I don’t think this is the case most of the time, I have received the error on my own end intermittently. If my firewall was blocking the request I would have expected it to happen more often.
  • Cloudflare CDN (which Supabase uses in production) blocking production traffic : This is something we have absolutely no control over right?
  • Edge Runtime failing to respond due to an internal issue (this is the part we can focus on and try to reduce from happening) - This is something we have no control over
  • Your edge function server implementation having an issue (usually these would be logged in Function logs) - We don’t get any function logs. Usually this error happens on the client side and the edge function is never even invoked. Based on what you are saying, this indicates that it is not a problem with our function server right?

We already have retries and error handling built into our site, but that doesn’t fix the problem, and it doesn’t seem like there is a path forward on my end to solve the problem.

I hope you can find how incredible frustrating this is on our end. We really love supabase, and would really love to stay on supabase edge functions, but I’m starting to think we have to move off unless you are able to indicate to us that this is something that you can solve within the next month or so.