supabase / cli

Supabase CLI. Manage postgres migrations, run Supabase locally, deploy edge functions. Postgres backups. Generating types from your database schema.
https://supabase.com/docs/reference/cli/about
MIT License
1.07k stars 209 forks source link

Api gateway idle request timeout is set to 60s in local stack #2434

Closed ggalmeida0 closed 4 months ago

ggalmeida0 commented 5 months ago

Describe the bug Hello!

I have an edge function which calls a LLM API as dependency, and this LLM API can take a while to respond, about 60s+

I'm consistently getting a 504 Gateway timeout at the 60s mark, which I believe is from the Kong API Gateway that has a 60s timeout by default.

In the production supabase hosted functions, the idle timeout is 150s according to the docs. I've tested my API with the deployed edge function and my API call succeeds as gateway allows for the request to go beyond the 60s mark.

My thought is the timeout of the local stack kong being 60s must be an oversight, since the prod versions support more. Are we able to increase the kong timeout to 150s to match the prod version? I'm free to help if needed.

Also, I'm somewhat new to supabase so let me know if I'm misunderstanding anything.

To Reproduce Steps to reproduce the behavior:

  1. supabase start
  2. serve an edge function locally and in the code add a sleep function like setTimeout to wait for 70s
  3. call the function with a http client like curl or insomnia
  4. See the 504 error show up at the 60s mark

Expected behavior The kong api gateway should allow idle requests to go up to 150s

Screenshots Screenshot_20240614_205752

System information Rerun the failing command with --create-ticket flag.

Zoz24 commented 5 months ago

Following, have same problem

sweatybridge commented 4 months ago

I've increased the timeout to 150s in cli beta release.

npx supabase@beta start
Zoz24 commented 4 months ago

I've increased the timeout to 150s in cli beta release.

npx supabase@beta start

@sweatybridge I believe the same problem also exists for memory limit. When I locally run a function that contains a sizable image my function being terminated for exceeding memory. However when the edge function is deployed there isn't any memory issue so the underlying cause is probably the same. Is there an existing issue for this bug as well?

sweatybridge commented 4 months ago

I believe the same problem also exists for memory limit.

You are right. I will address this in another release https://github.com/supabase/cli/issues/2500

Thank you for spotting these inconsistencies.