Yeah it looks pretty straight forward.
Since it looks like you’re not touching the response, only thing I would try would be to remove ‘const res = await next();’, your first line, and not return anything. That’s what we do in all of our functions except a couple that do some regex replacement of response body.
I’d also add some logging inside your catch block so you can hopefully trace something in the netlify edge function log.
Thanks for the suggestion. I’ll definitely try it.
I think something has been changed internally on Netfily side because the function is no longer setting a cookie (when it does work) and I now have correct preview images in the Netlify admin.
Furthermore, I did try and log the errors in the catch, however it ended up bringing the entire site down by doing so, so had to revert. I do need to revisit that as to why that way. Highly likely that it was a code error.
We’ve replied on your helpdesk ticket on this topic, feel free to reply on it.
All the best
After some back and forth, trial and error, and some investigation by the team on your side, it was found that the package you use internally to interact and set cookies with didn’t like the fact that the value I was storing in the cookie contained a space in it. Using
encodeURI to encode the value seems to have fixed this problem entirely!
Also sounds like there were a number of errors being logged internally that were not surfaced to site owners, which could have assisted in debugging this much quicker. From what I’ve been told, its being worked on to improve the error logging of the edge functions.
All in all, good outcome in the end.
We are facing the same exact problems detailed on this thread. Our edge functions are simple. We get sporadic errors even though nothing shows up in the logs at all, and the downstream providers we use for data, do not show any errors at all. is this a known problem with edge now?