supabase: Getting 502 Error from Edge Function

Bug report

Describe the bug

Hey all! I’m building a relatively simple edge function that just takes a request body, validates it, and saves it in the db. and for some reason, I can’t figure out why but I keep getting a 502 response from this endpoint.

I’ve tried deleting and redeploying the function. I’ve tried commenting out most/all of the function but a response in an effort of trying to isolate if it’s a package issue, supabase connection issue, etc… and nothing has worked.

Here’s a codepen with the code for my edge function: https://codesandbox.io/s/strange-wilson-ylnfpp?file=/src/functions/create-event/index.ts

I copied and pasted the example found here: https://github.com/supabase/supabase/blob/master/examples/edge-functions/supabase/functions/select-from-table-with-auth-rls/index.ts and that function is working fine. But for some reason my function is returning the following error:

502: Bad Gateway (ORIGIN_BOOT_RPC_ERROR)
The subhoster origin returned a failure status for the boot RPC call. Status: 500 Internal Server Error

To Reproduce

Expected behavior

In my project, I’d expect the function to take the in the body, validate it, store a new record, and return a non 500 response

System information

  • WSL (Ubuntu)
  • Version of supabase-js: 1.35.2
  • Version of Node.js: 16.13.1

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (4 by maintainers)

Most upvoted comments

@laktek Thank you for the information. I’ve redeployed the function and it works! Great, thank you so much!

@JanLoebel We recently made a fix that might solve this issue. Can you try deploying your function again?

Hi @Silur, you should get an error when deploying a function greater than the script size allowed by your plan. Are not able to see that error during the deployment?

@paddyfink yes, the script size was the issue! Going to close the issue now, but always curious how we can improve the docs/experience to make this issue more obvious to avoid future issues of the same nature.

I would be shocked if this is the case for me, as I started experiencing this behavior on a POC type project that was only called a handful of times prior to hitting this roadblock.

EDIT: Just realized that memory limit was unrelated to usage and related to script size, as seen on this page as being 1MB for the free tier. This would make a lot of sense considering I brought joi in for validation. I’ll try switching the validation to be pure TS and see if that works.