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
6aef15dc
Unverified
Commit
6aef15dc
authored
Jan 27, 2022
by
JJ Kasper
Committed by
GitHub
Jan 27, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure non-error thrown in getStaticPaths shows correctly (#33753)
parent
7ec49be7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
1 deletion
+41
-1
index.ts
packages/next/build/index.ts
+1
-1
index.test.js
...lid-page-automatic-static-optimization/test/index.test.js
+40
-0
No files found.
packages/next/build/index.ts
View file @
6aef15dc
...
@@ -1028,7 +1028,7 @@ export default async function build(
...
@@ -1028,7 +1028,7 @@ export default async function build(
)
)
}
}
}
catch
(
err
)
{
}
catch
(
err
)
{
if
(
isError
(
err
)
&&
err
.
message
!==
'INVALID_DEFAULT_EXPORT'
)
if
(
!
isError
(
err
)
||
err
.
message
!==
'INVALID_DEFAULT_EXPORT'
)
throw
err
throw
err
invalidPages
.
add
(
page
)
invalidPages
.
add
(
page
)
}
}
...
...
test/integration/invalid-page-automatic-static-optimization/test/index.test.js
View file @
6aef15dc
/* eslint-env jest */
/* eslint-env jest */
import
fs
from
'fs-extra'
import
path
from
'path'
import
path
from
'path'
import
{
nextBuild
}
from
'next-test-utils'
import
{
nextBuild
}
from
'next-test-utils'
...
@@ -15,4 +16,43 @@ describe('Invalid Page automatic static optimization', () => {
...
@@ -15,4 +16,43 @@ describe('Invalid Page automatic static optimization', () => {
expect
(
stderr
).
toMatch
(
/pages
\/
invalid/
)
expect
(
stderr
).
toMatch
(
/pages
\/
invalid/
)
expect
(
stderr
).
toMatch
(
/pages
\/
also-invalid/
)
expect
(
stderr
).
toMatch
(
/pages
\/
also-invalid/
)
})
})
it
(
'handles non-error correctly'
,
async
()
=>
{
const
testPage
=
path
.
join
(
appDir
,
'pages/[slug].js'
)
await
fs
.
rename
(
path
.
join
(
appDir
,
'pages'
),
path
.
join
(
appDir
,
'pages-bak'
))
await
fs
.
ensureDir
(
path
.
join
(
appDir
,
'pages'
))
await
fs
.
writeFile
(
testPage
,
`
export default function Page() {
return <p>hello world</p>
}
export function getStaticPaths() {
throw 'invalid API token'
}
export function getStaticProps() {
return {
props: {
hello: 'world'
}
}
}
`
)
try
{
const
{
stderr
}
=
await
nextBuild
(
appDir
,
[],
{
stderr
:
true
})
expect
(
stderr
).
toMatch
(
/invalid API token/
)
expect
(
stderr
).
not
.
toMatch
(
/without a React Component/
)
}
finally
{
await
fs
.
remove
(
path
.
join
(
appDir
,
'pages'
))
await
fs
.
rename
(
path
.
join
(
appDir
,
'pages-bak'
),
path
.
join
(
appDir
,
'pages'
)
)
}
})
})
})
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