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
918cf38d
Unverified
Commit
918cf38d
authored
Apr 21, 2020
by
JJ Kasper
Committed by
GitHub
Apr 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure to not show _error without 404 warning in some cases (#12061)
parent
b73b2ef8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
2 deletions
+26
-2
next-server.ts
packages/next/next-server/server/next-server.ts
+2
-1
index.test.js
test/integration/custom-error/test/index.test.js
+24
-1
No files found.
packages/next/next-server/server/next-server.ts
View file @
918cf38d
...
...
@@ -1321,7 +1321,8 @@ export default class Server {
if
(
process
.
env
.
NODE_ENV
!==
'production'
&&
!
using404Page
&&
(
await
this
.
hasPage
(
'/_error'
))
(
await
this
.
hasPage
(
'/_error'
))
&&
!
(
await
this
.
hasPage
(
'/404'
))
)
{
this
.
customErrorNo404Warn
()
}
...
...
test/integration/custom-error/test/index.test.js
View file @
918cf38d
...
...
@@ -13,6 +13,7 @@ import {
jasmine
.
DEFAULT_TIMEOUT_INTERVAL
=
1000
*
60
*
2
const
appDir
=
join
(
__dirname
,
'..'
)
const
page404
=
join
(
appDir
,
'pages/404.js'
)
const
nextConfig
=
join
(
appDir
,
'next.config.js'
)
let
appPort
let
app
...
...
@@ -27,6 +28,29 @@ const runTests = () => {
const
customErrNo404Match
=
/You have added a custom
\/
_error page without a custom
\/
404 page/
describe
(
'Custom _error'
,
()
=>
{
describe
(
'dev mode'
,
()
=>
{
let
stderr
=
''
beforeAll
(
async
()
=>
{
appPort
=
await
findPort
()
app
=
await
launchApp
(
appDir
,
appPort
,
{
onStderr
(
msg
)
{
stderr
+=
msg
||
''
},
})
})
afterAll
(()
=>
killApp
())
it
(
'should not warn with /_error and /404 when rendering error first'
,
async
()
=>
{
stderr
=
''
await
fs
.
writeFile
(
page404
,
'export default <h1>'
)
const
html
=
await
renderViaHTTP
(
appPort
,
'/404'
)
await
fs
.
remove
(
page404
)
expect
(
html
).
toContain
(
'Module build failed'
)
expect
(
stderr
).
not
.
toMatch
(
customErrNo404Match
)
})
})
describe
(
'dev mode'
,
()
=>
{
let
stderr
=
''
...
...
@@ -42,7 +66,6 @@ describe('Custom _error', () => {
it
(
'should not warn with /_error and /404'
,
async
()
=>
{
stderr
=
''
const
page404
=
join
(
appDir
,
'pages/404.js'
)
await
fs
.
writeFile
(
page404
,
`export default () => 'not found...'`
)
const
html
=
await
renderViaHTTP
(
appPort
,
'/404'
)
await
fs
.
remove
(
page404
)
...
...
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