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
7767a42f
Unverified
Commit
7767a42f
authored
Feb 24, 2020
by
JJ Kasper
Committed by
GitHub
Feb 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure to log errors from data fetching in dev mode in the console (#10652)
parent
91a47324
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
1 deletion
+30
-1
render.tsx
packages/next/next-server/server/render.tsx
+1
-0
index.js
test/integration/prerender/pages/index.js
+2
-0
index.test.js
test/integration/prerender/test/index.test.js
+27
-1
No files found.
packages/next/next-server/server/render.tsx
View file @
7767a42f
...
...
@@ -526,6 +526,7 @@ export async function renderToHTML(
if
(
!
dev
||
!
err
)
throw
err
ctx
.
err
=
err
renderOpts
.
err
=
err
console
.
error
(
err
)
}
if
(
unstable_getServerProps
&&
!
isFallback
)
{
...
...
test/integration/prerender/pages/index.js
View file @
7767a42f
...
...
@@ -2,6 +2,7 @@ import Link from 'next/link'
// eslint-disable-next-line camelcase
export
async
function
unstable_getStaticProps
()
{
// throw new Error('oops from getStaticProps')
return
{
props
:
{
world
:
'world'
,
time
:
new
Date
().
getTime
()
},
// bad-prop
...
...
@@ -12,6 +13,7 @@ export async function unstable_getStaticProps() {
const
Page
=
({
world
,
time
})
=>
{
return
(
<>
{
/* <div id='after-change'>idk</div> */
}
<
p
>
hello
{
world
}
<
/p
>
<
span
>
time
:
{
time
}
<
/span
>
<
Link
href
=
"/another?hello=world"
as
=
"/another/?hello=world"
>
...
...
test/integration/prerender/test/index.test.js
View file @
7767a42f
...
...
@@ -19,11 +19,13 @@ import {
normalizeRegEx
,
startStaticServer
,
initNextServerScript
,
getReactErrorOverlayContent
,
}
from
'next-test-utils'
jasmine
.
DEFAULT_TIMEOUT_INTERVAL
=
1000
*
60
*
2
const
appDir
=
join
(
__dirname
,
'..'
)
const
nextConfig
=
join
(
appDir
,
'next.config.js'
)
const
indexPage
=
join
(
__dirname
,
'../pages/index.js'
)
let
app
let
appPort
let
buildId
...
...
@@ -413,6 +415,31 @@ const runTests = (dev = false) => {
// )
// })
it
(
'should log error in console and browser in dev mode'
,
async
()
=>
{
const
origContent
=
await
fs
.
readFile
(
indexPage
,
'utf8'
)
const
browser
=
await
webdriver
(
appPort
,
'/'
)
expect
(
await
browser
.
elementByCss
(
'p'
).
text
()).
toMatch
(
/hello.*
?
world/
)
await
fs
.
writeFile
(
indexPage
,
origContent
.
replace
(
'// throw new'
,
'throw new'
)
.
replace
(
'{/* <div'
,
'<div'
)
.
replace
(
'</div> */}'
,
'</div>'
)
)
await
browser
.
waitForElementByCss
(
'#after-change'
)
// we need to reload the page to trigger getStaticProps
await
browser
.
refresh
()
const
errOverlayContent
=
await
getReactErrorOverlayContent
(
browser
)
await
fs
.
writeFile
(
indexPage
,
origContent
)
const
errorMsg
=
/oops from getStaticProps/
expect
(
stderr
).
toMatch
(
errorMsg
)
expect
(
errOverlayContent
).
toMatch
(
errorMsg
)
})
it
(
'should always call getStaticProps without caching in dev'
,
async
()
=>
{
const
initialRes
=
await
fetchViaHTTP
(
appPort
,
'/something'
)
expect
(
initialRes
.
headers
.
get
(
'cache-control'
)).
toBeFalsy
()
...
...
@@ -433,7 +460,6 @@ const runTests = (dev = false) => {
})
it
(
'should error on bad object from getStaticProps'
,
async
()
=>
{
const
indexPage
=
join
(
__dirname
,
'../pages/index.js'
)
const
origContent
=
await
fs
.
readFile
(
indexPage
,
'utf8'
)
await
fs
.
writeFile
(
indexPage
,
...
...
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