next.js: "ENOENT: no such file or directory" - next.js crashes, related to image caching?
Run next info
(available from version 12.0.8 and up)
root@1d90163fc150:/app# npx --no-install next info
/bin/sh: 1: pnpm: not found
Operating System:
Platform: linux
Arch: x64
Version: #1 SMP Debian 4.19.171-2 (2021-01-30)
Binaries:
Node: 17.4.0
npm: 8.3.1
Yarn: 1.22.17
pnpm: N/A
Relevant packages:
next: 12.0.10
react: 17.0.2
react-dom: 17.0.2
What version of Next.js are you using?
12.0.10
What version of Node.js are you using?
17.4.0
What browser are you using?
Chrome
What operating system are you using?
Debian
How are you deploying your application?
next build
Describe the Bug
Upgraded my site to next.js 12.0.10 and with the new release started getting errors;
today at 2:27:38 PMready - started server on 0.0.0.0:3000, url: http://localhost:3000
today at 2:27:38 PMinfo - Loaded env from /app/.env.production
today at 2:27:38 PMinfo - Loaded env from /app/.env
today at 2:27:39 PMwarn - SWC minify beta enabled. https://nextjs.org/docs/messages/swc-minify-enabled
today at 2:37:32 PMError: ENOENT: no such file or directory, open '/app/.next/cache/images/iLU6LIXA6TCl8SepFjJ5LNbyzLiOqZ7U49T1Ftm+jW4=/0.1643714865404.blKDVxGlp5+pf7TBeZBnD7i-BF2A5hQCHH0jGL--cVU=.avif'
and then next server dies and restarts
Expected Behavior
shouldnât be crashing.
To Reproduce
any code with avif + image caching support i guess
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 31
- Comments: 31 (10 by maintainers)
Commits related to this issue
- Fix image cache race condition (#33883) - Fixes #33860 — committed to vercel/next.js by styfle 2 years ago
- fix: corrected crash due to missing file, downgraded nextjs https://github.com/vercel/next.js/issues/33860 — committed to szabolcs-szilagyi/myna-nextjs by szabolcs-szilagyi 2 years ago
- Force usage of next 12.0.9 See: https://github.com/vercel/next.js/issues/33860 — committed to Snaacky/theindex by Yasamato 2 years ago
- Use updated recursive rm fs method for image-optimizer (#34210) This ensures we handle `EEXISTS` with `fs.rmdir` for Node.js `v12` and use `fs.rm` when available instead as it is the replacement for ... — committed to vercel/next.js by ijjk 2 years ago
- Upgrade 'next' package from '12.0.10' to 'canary'. Reason: https://github.com/vercel/next.js/issues/33860 — committed to gabrielrochamd/v1 by gabrielrochamd 2 years ago
- Fix image cache race condition (#33883) - Fixes #33860 — committed to natew/next.js by styfle 2 years ago
- fix(nextjs): bump nextjs to 12.1.0 to fix webp crash error 2022-02-22T10:28:12.259 client-tst Error: ENOENT: no such file or directory, open '/app/.next/cache/images/jyLfZatL4kb....bk5QE=/0.164552196... — committed to viaacode/hetarchief-client by bertyhell 2 years ago
This is fixed on canary, thanks!
You can try it out today with
npm i next@canary
oryarn add next@canary
.I also discovered that serving stale images wasnât any faster because revalidation wasnât happening in the background, it was blocking. So I created PR #33930 with the another fix. (Update: closed in favor of #34075)
Update: This has been released in Next.js 12.1.0
Wow thanks. This is one of those rare occasions that I search for an error, only to find it wasnât my mistake and fixed in the last few days đ
Sending appreciation for next@canary and nextjs team!
downgraded to 12.0.9 now and it seems all good, i think this may be the offfending commit: https://github.com/vercel/next.js/pull/33719
@styfle hey. Hereâs the repo that crashes: https://github.com/b-novikov-ipersonality/nextjs-cache-crash
yarn build
yarn start
http://localhost:3000
I have this error as well, @ijjk out of curiosity, when is 12.0.11 planned to be released? Knowing would help me in how I would like to work around this for now.
No more errors, thanks alot for the quick fix!
@yayza the above PR is now landed in
v12.0.11-canary.13
, please update and give it a try!Is the fix in 12.1?Just found it - it is in 12.1: https://github.com/vercel/next.js/commit/e3e62aa78673f8819583f56eb43c5cc9b4b9dd78
@yayza Ah I see, thanks for sharing that additional info, looks like this is an issue with writing to cache specifically with the
rmdir
method used to clean the dir. I opened a PR with a fix for this here https://github.com/vercel/next.js/pull/34210@joggienl they just released 12.1.0 today