Caching-related edge case in one of dependencies
See original GitHub issueWhat version of Next.js are you using?
11.0.1
What version of Node.js are you using?
15.14.0
What browser are you using?
Firefox
What operating system are you using?
Linux
How are you deploying your application?
next start
Describe the Bug
There’s an edge case in send
dependency used by nextjs that seems to be causing issues in production environments that use the built-in image optimization thing.
It has been reported several times (#19309 #23140), but no one found out the cause until now.
https://github.com/vercel/next.js/issues/19309#issuecomment-891758867
I think I have tracked the issue down, it’s related to one of nextjs dependencies:
when calling
send()
there’s a chance that if certain conditions are met, the code will attempt to send a “not modified” response: https://github.com/pillarjs/send/blob/de073ed3237ade9ff71c61673a34474b30e5d45b/index.js#L637…but the
res
property is not set before calling .pipe() and it’s where the crash usually happens:https://github.com/pillarjs/send/blob/de073ed3237ade9ff71c61673a34474b30e5d45b/index.js#L515 https://github.com/vercel/next.js/blob/canary/packages/next/server/serve-static.ts#L18
Expected Behavior
Said issue is not present and caching of image assets works properly.
To Reproduce
- The application must be running in production environment using
next start
and must use next.js built-in image optimization. - If certain resources are cached and conditions in code linked above are met, either a crash (due to unhandled promise rejection) or response timeout will happen.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:9
- Comments:6 (4 by maintainers)
The fix is available in Next.js 11.1.0, thanks!
Also note, you can use
sharp
for Image Optimization now 👍This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.