I am getting the error `The script will
I am getting the error
The script will never generate a response
when trying to use fetch() in my generateMetaData function in NextJS 14. I've seen a lot of similar bugs reported on this but haven't been able to find a solution. Is anyone familiar with this?
I can reproduce this locally when running npx @Cloudflare/next-on-pages@1 and then using wrangler to do a preview, otherwise this works on local.
The error I was getting before reproducing on local (in my dev cloudflare url) was A hanging Promise was canceled. This happens when the worker runtime is waiting for a Promise from JavaScript to resolve, but has detected that the Promise cannot possibly ever resolve because all code and events related to the Promise's I/O context have already finished.
4 Replies
This is the code that's causing it:
Are you sure it happens because of this metadata?
I am 99% sure it is because of the fetch call inside the metadata, but specifically the fetch(). I was able to avoid the crash by using a timeout on the promise, but it stills gives me the error just prevents the crash
I had a similar error, fixed with the edge runtime included in my server side component