Hi Netlify Community,
I am trying to deploy a Shopify hydrogen app to Netflify Edge Functions with the help of this package: GitHub - netlify/hydrogen-platform: Hydrogen support for Netlify Edge Functions
Site name: https://lively-pie-40c37f.netlify.app
The build successfully finishes, but when I try to open the link I’m getting a HTTP 502 error. Someone in the Shopify Discord suggested that it might have to do with the wrong AWS Lambda Node runtime of Netlify Functions, which I tried to solve via environment variables in the UI (like desribed here: AWS_LAMBDA_JS_RUNTIME - nodejs14.x - #2 by lambrospetrou) but this also didn’t help.
I’m really grateful for any hints.
You seem to be having issues due to Edge Functions. Could you disable those and try again?
Also, about the current error with Edge Functions, it’s already escalated to the developers. Once we hear back from them, we’ll let you know.
how can I disable Edge Functions? I believe the Netlify package was especially build for Edge Functions?
I meant, you could try using Hydrogen without using Edge Functions to see if the issue is solved - at least till we’re able to take a deeper dive in the Edge Function situation.
FYI, our team has found the root cause of this problem. Your edge function must begin returning at least HTTP response headers (it can wait somewhat longer to return more data, such as the body) within 40 seconds, or we will stop executing. Your edge functions do not seem to do so, and thus they are killed off at 40 seconds by us as we assume they are not going to work and will not keep the idle connection open for longer.
This is a (now) documented limitation of the service: Edge Functions limits | Netlify Docs
Thanks for getting back and please excuse my delay in response. Since I’m completely new to Edge Functions: Do I add a second Edge function to my hydrogen environment that returns custom headers (besides the handler/index.js)? Or does my handler/index.js need to return the headers?
If that’s a custom Edge Function that you’ve created, you need to edit that one to add the headers. No need to create yet another Edge Function.
Hi @hrishikesh @fool,
We’re experiencing the same problem. We don’t have an explicate edge function directory but I believe that Hydrogen automatically deploys server code to Edge Functions.
I suppose it’s possible that this code is exceeding the 40s timeout.
To help with debugging:
- Is there a way to view the edge function logs to find which part of our code is hanging?
- Is there a way for us to stop Hydrogen from deploying to Edge Functions as a test?
Indeed this is the case:
% time curl -I https://good-nature.netlify.app/
date: Mon, 05 Sep 2022 02:54:19 GMT
curl -I https://good-nature.netlify.app/ 0.01s user 0.01s system 0% cpu 40.336 total
You should see logs on the URL included in your post (if anything is logged.)
I don’t see anything in the Hydrogen on Netlify documentation, nor the @netlify/hydrogen-platform repository about the possibility of this. In fact in the documentation is states
Hydrogen apps on Netlify work because of Netlify Edge Functions, which are currently in the beta stage.
@coelmay thank you for the confirmation!
Unfortunately the logs are perpetually hanging. Furthermore the console has a few CORS errors. Is this something you’ve come across before?
It’s making it pretty difficult to debug.
I’ve replied in the helpdesk but here’s it for everyone else:
Edge Functions would only show logs if:
- You deliberately log something using
- It generates some error and thus, the code raises as exception that’s thrown
Unlike Netlify Functions, they won’t generate access logs at the moment - that is you won’t be able to know if an Edge Function was actually invoked.
You can try logging in something to see if it’s working.