We just now started getting errors for our pages. The error message is as follows:
This edge function has crashed
An unhandled error in the function code triggered the following message:
The deployment failed while serving the request.
Netlify internal ID: 01GXWWMANQJ6F77DPB34Q43GAB
We’re using edge functions for some rewrites and for image optimization.
Looking at the edge functions log it says the following: “Apr 13, 10:41:37 AM: error An edge function failed to initialize due to an internal error. Please reach out to Netlify support.”.
This is for deploy id 6437bf2e4c108b0008f6e85b for my site ba2febd5-460e-4cc1-9476-36a9938140ce.
I’m using NextJS middleware. Removing the middleware allows us to reach the site again. However the images all fail to load. I believe that this is due to the fact that we’re using NEXT_FORCE_EDGE_IMAGES which is running edge functions for image optimization.
I have now disabled NEXT_FORCE_EDGE_IMAGES and the images load properly again. Still, we need this to work. Especially crucial is the middleware since it’s handling all of the redirects.
I have reproduced this on my stage site (e0c5d382-f9e0-4200-bf77-14635292a363) by triggering a new deploy. The site is unavailable and always gives a 502 error.
Calling an API endpoint also returns 502 - “The deployment failed while serving the request.”.
Example x-nf-request-id: 01GXX0PMFNNDBN58PY47W9BV2E
The edge functions log says the same as it did for my production site:
Apr 13, 11:55:14 AM: error An edge function failed to initialize due to an internal error. Please reach out to Netlify support.
We’re really sorry this didn’t work for you, we were dealing with a small issue in our pipeline that impacted a small amount of sites using this feature. The good news is that this issue is solved now.
It should be possible to use NEXT_FORCE_EDGE_IMAGES again now. I hope you’ll encounter no further issues, but feel free to let us know if you do. And thank you for your detailed question!
Thanks for the update, image optimization using NEXT_FORCE_EDGE_IMAGES is now working again.
Even though this was considered as a small issue on your end, our site was completely inaccessible. Should issues like these not be highlighted on https://www.netlifystatus.com/?
This happens very frequently for Edge functions on NextJs built on Netlify. I cannot figure out why. We had to just refactor and remove all our edge functions (still a few left), and remove middleware to get our site to function reliably. A bit disappointing because Edge functions are amazing for various reasons. But, NextJs Edge functions just don’t function reliably on Netlify for some reason. I do not think Deno was a good choice here for Netlify. If they host NextJs website that got to use the same platform as Vercel, Cloudflare V8 some other V8 engine, all of which are well out of beta and function very reliably. What we will probably due, since Netlify is actually a much better hosting platform than Vercel in other respects is to just use Cloudflare Workers for Edge and call the cloudflare workers within the netlify app. You can build your own type of middleware basically by doing that.
I don’t think you will have much problems if you just run the serverless functions on Cloudflare Workers (v8) directly or even just run them directly on Netlify Edge (still in beta), as opposed to in the NextJs app. The serverless functions on these hosting platforms, like Netlify and Vercel, are just built on top of some other platform, which you can use directly on your own. The downside is that you separate out the functions from the existing app, so you need to manage 2 repos basically. On the upside, though, you have better scalability and reliability. It’s a tough decision…Also, i think it’s critical to not put everything on the edge. Really only need it for parts of the application that need an immediate response. Otherwise, a short delay for better reliability is not that big of deal…
Sure you could run the edge functions somewhere else, however that’s not really an option for us at the moment since our dev team is incredibly small and we want to keep the complexity of our stack as simple as possible.
Worth noting is that Netlify edge functions are still in beta, so you have to expect some issues from time to time. However a complete site outage like in our case shouldn’t happen. Not considering the netlify edge functions I’d argue that Netlify is incredibly scalable as well as reliable.
Agree 100%. That’s why I stick with them. As for dev team, I am a team of 1, and I find working on edge functions elsewhere is much easier. You don’t have to worry about deploying the entire site when working on a serverless function. If you locate your functions in the same deploy as the app, you need to rebuild the entire site to get the new functions to deploy. It’s just the biggest pain imaginable and you risk errors. If you are doing it on another platform, you don’t need to worry about this. Much less room for errors.