Edge Function 504 Timeout on Concurrent Requests

Issue: PostgreSQL trigger calls edge function via supabase_functions.http_request(). Concurrent identical requests result in: - ✅ Request A: Success (12s)
- ❌ Request B: 504 timeout (150s) Environment: @supabase/supabase-js@2, PostgreSQL triggers, Deno edge functions Evidence from invocation logs:
// Successful
{"deployment_id": "abc_123", "status_code": 200, "execution_time_ms": 12317}

// Failed
{"deployment_id": null, "status_code": 504, "execution_time_ms": 150235, "function_id": null}
// Successful
{"deployment_id": "abc_123", "status_code": 200, "execution_time_ms": 12317}

// Failed
{"deployment_id": null, "status_code": 504, "execution_time_ms": 150235, "function_id": null}
Key Issue: deployment_id: null suggests request never reached function instance. Same trigger/payload but different outcomes. Trigger:
EXECUTE FUNCTION supabase_functions.http_request (
'https://project.supabase.co/functions/v1/my-function',
'POST',
'{"Content-type":"application/json"}',
FORMAT('{"record":{"id":%s}}', NEW.id),
'7500'
);
EXECUTE FUNCTION supabase_functions.http_request (
'https://project.supabase.co/functions/v1/my-function',
'POST',
'{"Content-type":"application/json"}',
FORMAT('{"record":{"id":%s}}', NEW.id),
'7500'
);
Workaround: PERFORM pg_sleep(random() * 2); Question: Is this expected for concurrent edge function calls? Seems like gateway routing issue vs application code. Anyone else seeing 504s with deployment_id: null? Tags: edge-functions database triggers
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?