Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next.js + SSR + Cache: ENOENT when loading images sharp version 0.30.0 #3078

Closed
MrUddh opened this issue Feb 8, 2022 · 6 comments
Closed
Labels

Comments

@MrUddh
Copy link

MrUddh commented Feb 8, 2022

Are you using the latest version? Is the version currently in use as reported by npm ls sharp the same as the latest version as reported by npm view sharp dist-tags.latest?

  • Yes

What are the steps to reproduce?

  • I recently upgrade my page from "sharp": "0.29.3", to "sharp": "^0.30.0". After that I experienced random crashes and pictures that don't show up due to server down.

What is the expected behaviour?

  • Load more images shouldn't break the site

Are you able to provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem?

0|app      | node:events:368
0|app      |       throw er; // Unhandled 'error' event
0|app      |       ^
0|app      |
0|app      | Error: ENOENT: no such file or directory, open '/home/roy/ssr/.next/cache/images/YRsy75nIks7e4R6AD5Hn9pEllmNFpdigk3kmseeqg0o=/0.1644326694486.aj2IPGTFeDoaLL--dpJlGdzuHmMYn7dGqUlEy99ouRc=.webp'
0|app      | Emitted 'error' event on ReadStream instance at:
0|app      |     at emitErrorNT (node:internal/streams/destroy:157:8)
0|app      |     at emitErrorCloseNT (node:internal/streams/destroy:122:3)
0|app      |     at processTicksAndRejections (node:internal/process/task_queues:83:21) {
0|app      |   errno: -2,
0|app      |   code: 'ENOENT',
0|app      |   syscall: 'open',
0|app      |   path: '/home/roy/ssr/.next/cache/images/YRsy75nIks7e4R6AD5Hn9pEllmNFpdigk3kmseeqg0o=/0.1644326694486.aj2IPGTFeDoaLL--dpJlGdzuHmMYn7dGqUlEy99ouRc=.webp'
0|app      | }

Are you able to provide a sample image that helps explain the problem?

  • no

What is the output of running npx envinfo --binaries --system?

Next.js version: 12.0.7

  System:
    OS: Linux 5.4 Ubuntu 20.04.3 LTS (Focal Fossa)
    CPU: (4) x64 DO-Regular
    Memory: 5.01 GB / 7.77 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 16.13.2 - /usr/bin/node
    npm: 8.3.0 - /usr/bin/npm
@MrUddh MrUddh added the triage label Feb 8, 2022
@lovell
Copy link
Owner

lovell commented Feb 8, 2022

Hi, this looks like a Next.js caching or filesystem problem unrelated to sharp. Do the files that appear in the error message exist? Are you able to reproduce this using sharp alone?

For me to investigate, I'll need a minimal, standalone code sample, without other dependencies (this means without Next.js).

@lovell lovell added question and removed triage labels Feb 8, 2022
@lovell lovell changed the title Error when loading images sharp version 0.30.0 Next.js + SSR + Cache: ENOENT when loading images sharp version 0.30.0 Feb 8, 2022
@MrUddh
Copy link
Author

MrUddh commented Feb 8, 2022

Currently, we are using the version: "sharp": "0.29.3" and we never experienced any errors.
After upgrading to "sharp": "0.30.0", we started to get crashes when scrolling on page loading in more images. We haven't touched anything else. If you want to have a look: jiroy.com

@lovell
Copy link
Owner

lovell commented Feb 8, 2022

The filesystem paths in the error message look like they are from a SSR cache. I don't know how Next.js works, but at a guess it might use content-based hashing, so if you upgrade a dependency that generates content (e.g. sharp), the content-based hashes might also change. Have you tried clearing the SSR cache?

@MrUddh
Copy link
Author

MrUddh commented Feb 8, 2022

We cleared everything before upgrading so it shouldn't be that.
Can it be in conjunction with next.js 12 dropping sharp (ref) that the file hashing doesn't match anymore?

@lovell
Copy link
Owner

lovell commented Feb 8, 2022

vercel/next.js#33860

@MrUddh
Copy link
Author

MrUddh commented Feb 8, 2022

Thank you, my good sir, that ticket solved our issue as well.

Have a good one!

@lovell lovell closed this as completed Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants