Skip to content

Supabase invoke doing nothing, possibly due to stale TCP connection issue #678

@koenvanzuijlen

Description

@koenvanzuijlen

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

When calling supabase.functions.invoke from the Supabase JS library it sometimes does nothing at all and just hangs. No error and the invoked function is never triggered. In our production environment this happened 13 times out of 1772 over a specific period.

I filed this bug at the supabase-js repository (supabase/supabase-js#2184) and they think it is because of an issue with stale TCP connections.

A quote from their reply (see issue for full reply)

Why the invoked function never starts: The key symptom is that the callee never executes at all. This rules out a bug in how the SDK processes the response, the HTTP request is simply never delivered to the target function. What most likely happens:

  1. Deno's fetch maintains a pool of reusable HTTP keep-alive connections for performance
  2. When your edge function calls functions.invoke(...), Deno picks a connection from that pool
  3. If that connection was silently closed by the server (e.g. the relay recycled it after an idle period), Deno doesn't know, the OS-level write to the socket buffer succeeds without error
  4. The remote side drops the packet because the connection is already gone on its end, but no TCP RST or FIN makes it back to Deno in time to trigger a rejection
  5. fetch waits indefinitely for a response that will never come → your outer function times out, the inner function never received the request

I think that the right fix is at the infrastructure layer: the Supabase relay or the Deno edge runtime should either send proper keep-alive probes, enforce shorter idle timeouts on pooled connections, or retry automatically on a fresh connection when a send fails with no response.

To Reproduce

Note that this will only happen in rare cases (13 out of 1772) rate

await supabase.functions.invoke('function', {
  body: { foo: 'bar' }
})

Expected behavior

The invoked function is triggered as expected

System information

Node: 25.8.1
npm: 11.11.0
Deno: 2.7.5
supabase-js: 2.86.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions