question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Caching-related edge case in one of dependencies

See original GitHub issue

What 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:closed
  • Created 2 years ago
  • Reactions:9
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
styflecommented, Aug 12, 2021

The fix is available in Next.js 11.1.0, thanks!

Also note, you can use sharp for Image Optimization now 👍

0reactions
balazsorban44commented, Jan 27, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What Are Edge Cases in Software Testing? - 2022 Edition
Software testing edge cases are bugs that are uncommon for users to encounter. Edge cases can be minor - or as severe as...
Read more >
Python packaging edge cases - 921Kiyo
Python packaging is one of those things that doesn't work in some cases, and I'm going to demonstrate one such case in this...
Read more >
HTTP response status codes - MDN Web Docs - Mozilla
HTTP response status codes indicate whether a specific HTTP request has been successfully completed. Responses are grouped in five classes:
Read more >
realtime updater design and configuration - Google Groups
Hi again everyone, On Tuesday Jaap, Jorden, and I had a discussion about applying real-time updates and configuring realtime graph updater modules.
Read more >
Rhodes Goerzen THIRD EDITION
for a variety of tasks, you will benefit from all of the edge cases and awkward corners ... a Python interpreter, and any...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found