Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
39e5570b
Unverified
Commit
39e5570b
authored
Aug 14, 2026
by
Steven
Committed by
GitHub
Aug 14, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(next/image): reject empty image on read/write to disk cache (#97278)
parent
ae0e0a50
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
1 deletion
+12
-1
errors.json
packages/next/errors.json
+3
-1
image-optimizer.ts
packages/next/src/server/image-optimizer.ts
+9
-0
No files found.
packages/next/errors.json
View file @
39e5570b
...
@@ -1470,5 +1470,7 @@
...
@@ -1470,5 +1470,7 @@
"1469"
:
"The payload's transport tree is missing a slot that exists in the loader tree: %s"
,
"1469"
:
"The payload's transport tree is missing a slot that exists in the loader tree: %s"
,
"1470"
:
"`deflateResumeDataCache` should not be called in edge runtime."
,
"1470"
:
"`deflateResumeDataCache` should not be called in edge runtime."
,
"1471"
:
"Cannot resolve a dynamic segment that has no param value: the response provides no rendered pathname to parse it from."
,
"1471"
:
"Cannot resolve a dynamic segment that has no param value: the response provides no rendered pathname to parse it from."
,
"1472"
:
"Cannot convert a server response with no transport data and no base tree."
"1472"
:
"Cannot convert a server response with no transport data and no base tree."
,
"1473"
:
"Invariant: image cache entry
\"
%s
\"
is empty"
,
"1474"
:
"Invariant: cannot write an empty buffer to the image cache"
}
}
packages/next/src/server/image-optimizer.ts
View file @
39e5570b
...
@@ -188,6 +188,12 @@ async function writeToCacheDir(
...
@@ -188,6 +188,12 @@ async function writeToCacheDir(
etag
:
string
,
etag
:
string
,
upstreamEtag
:
string
upstreamEtag
:
string
)
{
)
{
if
(
buffer
.
byteLength
===
0
)
{
throw
new
Error
(
'Invariant: cannot write an empty buffer to the image cache'
)
}
const
dir
=
join
(
/* turbopackIgnore: true */
cacheDir
,
cacheKey
)
const
dir
=
join
(
/* turbopackIgnore: true */
cacheDir
,
cacheKey
)
const
filename
=
join
(
const
filename
=
join
(
/* turbopackIgnore: true */
/* turbopackIgnore: true */
...
@@ -216,6 +222,9 @@ async function readFromCacheDir(cacheDir: string, cacheKey: string) {
...
@@ -216,6 +222,9 @@ async function readFromCacheDir(cacheDir: string, cacheKey: string) {
)
)
const
filePath
=
join
(
/* turbopackIgnore: true */
dir
,
file
)
const
filePath
=
join
(
/* turbopackIgnore: true */
dir
,
file
)
const
buffer
=
await
promises
.
readFile
(
/* turbopackIgnore: true */
filePath
)
const
buffer
=
await
promises
.
readFile
(
/* turbopackIgnore: true */
filePath
)
if
(
buffer
.
byteLength
===
0
)
{
throw
new
Error
(
`Invariant: image cache entry "
${
cacheKey
}
" is empty`
)
}
const
expireAt
=
Number
(
expireAtSt
)
const
expireAt
=
Number
(
expireAtSt
)
const
maxAge
=
Number
(
maxAgeSt
)
const
maxAge
=
Number
(
maxAgeSt
)
return
{
maxAge
,
expireAt
,
etag
,
upstreamEtag
,
buffer
,
extension
}
return
{
maxAge
,
expireAt
,
etag
,
upstreamEtag
,
buffer
,
extension
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment