We are having continued problems with Edge functions on Nextjs. On some deploys the edge functions get built and work perfectly fine. Then on other builds, the edge functions are supposedly built, but a fetch to the function will return an error that the function is not there (i.e. doesn’t exist). the code on our end hasn’t changed at all. it’s just the deploy is messed up on build. Overall, this is incredibly unreliable. I guess we will have to move back to regular functions, because having the site work on one build and then fail on the next build is not viable. What’s even stranger is the edge functions will work fine on a development branch, and then on production build and vice versa. There is no rhyme or reason here. The logs show the edge functions are built, but they are not there when a fetch is made.
Even though, I really don’t understand what is happening behind the scenes with Netlify and NextJs, my guess is that edge functions on Nextjs when hosted on Netlify are unreliable due to occassional build errors when Netlify transforms these functions into Netlify Edge based on Deno. I have no other explanation as to why these functions just randomly fail on some builds and not others. Netlify should use Cloudflare V8 for NextJs Edge functions, like Vercel does, and forget about transforming them. But, this might not be possible b/c Netlify Edge only runs on Deno? If so, I don’t think Deno is a great for edge for Nextjs. Seems very unreliable, at least for NextJs
We need a site name to check/debug/suggest anything.
We had to refactor into Node, instead of Edge, as Edge was just very unpredictable. There was nothing special about our code. It was simple Edge functions. Plus, we had the same issues as reported here many times on this forum by others. There seems to be some bug in deployment when Netlify transforms NextJs Edge functions in Deno. Sometimes it works and sometimes not. The bugs are: 1. Sometimes edge functions that supposedly are deployed are simply not there. They show in deployment, but calling them returns an error b/c the function is not found. The other error is that often Edge functions will just randomly crash out of nowhere for no apparent reason. Both of these errors have been reported by others, so nothing unique here.
Hi we will need to know what site you are referring to so we can check and confirm/deny if it’s a bug and help you troubleshoot. Would you mind sharing this or your slug?