New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
supabase functions serve runs out of memory and crashes with basic usage #212
Comments
We've noticed this to, having to start the serve functionality periodically when the edge functions dies. |
Transferring to edge-runtime repo since it likely requires changes to the container. |
Hey! @meyer9 The root reason causing the leak memory is at the Deno code base I think. |
This policy forces the supervisor to terminate the isolation immediately if the request is complete. Using this policy with development will make sense because it terminates the isolation immediately if the request is complete, so developers will not have to restart runtime. This commit solves cases such as supabase#192 and supabase#212
I had to use the cargo patch to fix the memory leakage problem because the root cause of the memory leak belonged to `deno_core`. Eventually, these changes should be tracked at `deno_core`; so until fixing this problem upstream, we have to use the patch. It could be the substantial solution for supabase#212 and supabase#192 (on the assumption that I found all memory leakage places of `JsRuntime` 😋 For reference, Valgrind no longer reported definite memory leakage after this patch)
Until then, are there any suggestions on how to do some sort of hacky reboot-serve every n requests without the server responses failing? |
Hi! @jeremyisatrecharm 😋 Yeah, the Deno team seems to be taking longer time than I expected to fix the memory leak. It may not be a priority for them. So, I've already written some commits to fix the memory leak into my fork. However, since these changes modify the upstream directly, it may be necessary to talk with the supabase team about whether to accept this. Just in time, @laktek is back from holiday, so I'd like to take the time to discuss this 😁 |
I had to use the cargo patch to fix the memory leakage problem because the root cause of the memory leak belonged to `deno_core`. Eventually, these changes should be tracked at `deno_core`; so until fixing this problem upstream, we have to use the patch. It could be the substantial solution for supabase#212 and supabase#192 (on the assumption that I found all memory leakage places of `JsRuntime` 😋 For reference, Valgrind no longer reported definite memory leakage after this patch) (cherry picked from commit bc631b4)
This policy forces the supervisor to terminate the isolation immediately if the request is complete. Using this policy with development will make sense because it terminates the isolation immediately if the request is complete, so developers will not have to restart runtime. This commit solves cases such as supabase#192 and supabase#212 (cherry picked from commit 0b1ddd0)
This policy forces the supervisor to terminate the isolation immediately if the request is complete. Using this policy with development will make sense because it terminates the isolation immediately if the request is complete, so developers will not have to restart runtime. This commit solves cases such as supabase#192 and supabase#212 (cherry picked from commit 0b1ddd0)
This policy forces the supervisor to terminate the isolation immediately if the request is complete. Using this policy with development will make sense because it terminates the isolation immediately if the request is complete, so developers will not have to restart runtime. This commit solves cases such as supabase#192 and supabase#212 (cherry picked from commit 0b1ddd0)
I had to use the cargo patch to fix the memory leakage problem because the root cause of the memory leak belonged to `deno_core`. Eventually, these changes should be tracked at `deno_core`; so until fixing this problem upstream, we have to use the patch. It could be the substantial solution for supabase#212 and supabase#192 (on the assumption that I found all memory leakage places of `JsRuntime` 😋 For reference, Valgrind no longer reported definite memory leakage after this patch) (cherry picked from commit bc631b4) # Conflicts: # Cargo.lock # Cargo.toml
I had to use the cargo patch to fix the memory leakage problem because the root cause of the memory leak belonged to `deno_core`. Eventually, these changes should be tracked at `deno_core`; so until fixing this problem upstream, we have to use the patch. It could be the substantial solution for supabase#212 and supabase#192 (on the assumption that I found all memory leakage places of `JsRuntime` 😋 For reference, Valgrind no longer reported definite memory leakage after this patch) (cherry picked from commit bc631b4)
I'm running into this issue as well (at least I think it is the same issue) - I can't run any function that attempts to work any sort of embeddings. Each invocation fails with:
|
There seem to be a few issues mentioned here but the project documentation is completely absent (except for the If you are getting errors like :
Then make sure you are passing sufficiently large limits to your worker. See https://github.com/supabase/edge-runtime/blob/main/examples/main/index.ts#L98 for an example. The defaults appear to be set extremely low (1000ms or something) so they are easy to hit if you are doing anything serious. Have a look at all the options. Increasing these made all my issues go away. |
Describe the bug
The edge-runtime does not terminate the worker for a few minutes after starting. This causes a pretty severe memory leak since a new worker is created for each request and never terminated: https://github.com/supabase/cli/blob/a0c8644deeef5a72f99687cc897eadc3dce256f1/internal/functions/serve/templates/main.ts#L135
This makes it effectively impossible to use
supabase functions serve
for local development.To Reproduce
Expected behavior
I expect the worker runtimes to be cleaned up after the request is complete if a new worker runtime is started for each request. Even nicer would be to reuse a single worker runtime and refresh it when files change, similar to
deno --watch
.Screenshots
Desktop (please complete the following information):
Additional context
Disabling
forceCreate
solves the crashing issue, but breaks auto-reload.I filed an issue on the edge-runtime here since I'm not sure which should be fixed to resolve the crashing problem. #192
The text was updated successfully, but these errors were encountered: