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
91cbf9d9
Unverified
Commit
91cbf9d9
authored
Nov 07, 2024
by
Jiachi Liu
Committed by
GitHub
Nov 07, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ignore error pages for cache revalidate (#72412) (#72484)
parent
27554305
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
3 deletions
+44
-3
base-server.ts
packages/next/src/server/base-server.ts
+5
-3
empty-ssg-fallback.test.ts
.../production/empty-ssg-fallback/empty-ssg-fallback.test.ts
+12
-0
[...slug].tsx
test/production/empty-ssg-fallback/pages/[...slug].tsx
+15
-0
_error.tsx
test/production/empty-ssg-fallback/pages/_error.tsx
+12
-0
No files found.
packages/next/src/server/base-server.ts
View file @
91cbf9d9
...
@@ -1733,9 +1733,11 @@ export default abstract class Server<ServerOptions extends Options = Options> {
...
@@ -1733,9 +1733,11 @@ export default abstract class Server<ServerOptions extends Options = Options> {
if
(
pathname
===
UNDERSCORE_NOT_FOUND_ROUTE
)
{
if
(
pathname
===
UNDERSCORE_NOT_FOUND_ROUTE
)
{
pathname
=
'/404'
pathname
=
'/404'
}
}
const
is404Page
=
pathname
===
'/404'
const
isErrorPathname
=
pathname
===
'/_error'
const
is404Page
=
const
is500Page
=
pathname
===
'/500'
pathname
===
'/404'
||
(
isErrorPathname
&&
res
.
statusCode
===
404
)
const
is500Page
=
pathname
===
'/500'
||
(
isErrorPathname
&&
res
.
statusCode
===
500
)
const
isAppPath
=
components
.
isAppPath
===
true
const
isAppPath
=
components
.
isAppPath
===
true
const
hasServerProps
=
!!
components
.
getServerSideProps
const
hasServerProps
=
!!
components
.
getServerSideProps
...
...
test/production/empty-ssg-fallback/empty-ssg-fallback.test.ts
0 → 100644
View file @
91cbf9d9
import
{
nextTestSetup
}
from
'e2e-utils'
describe
(
'empty-ssg-fallback'
,
()
=>
{
const
{
next
}
=
nextTestSetup
({
files
:
__dirname
,
})
it
(
'should not cache 404 error page'
,
async
()
=>
{
const
res
=
await
next
.
fetch
(
'/any-non-existed'
)
expect
(
res
.
status
).
toBe
(
404
)
})
})
test/production/empty-ssg-fallback/pages/[...slug].tsx
0 → 100644
View file @
91cbf9d9
export
const
getStaticPaths
=
async
()
=>
{
return
{
paths
:
[],
fallback
:
'blocking'
,
}
}
export
const
getStaticProps
=
async
()
=>
{
return
{
notFound
:
true
,
}
}
export
default
function
Page
()
{
return
<
p
>
slug
</
p
>
}
test/production/empty-ssg-fallback/pages/_error.tsx
0 → 100644
View file @
91cbf9d9
import
{
GetServerSidePropsContext
}
from
'next'
function
Error
({
statusCode
}:
{
statusCode
:
number
})
{
return
<
p
>
{
statusCode
?
`${statusCode} error`
:
'500 error'
}
</
p
>
}
export
async
function
getServerSideProps
({
res
}:
GetServerSidePropsContext
)
{
const
statusCode
=
res
?
res
.
statusCode
:
404
return
{
props
:
{
statusCode
}
}
}
export
default
Error
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