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
71ae456a
Commit
71ae456a
authored
Feb 22, 2019
by
JJ Kasper
Committed by
Tim Neutkens
Feb 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix invalid ping response throwing error in client (#6397)
parent
e0896e5d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
12 deletions
+15
-12
on-demand-entries-client.js
packages/next/client/on-demand-entries-client.js
+14
-12
on-demand-entry-handler.js
packages/next/server/on-demand-entry-handler.js
+1
-0
No files found.
packages/next/client/on-demand-entries-client.js
View file @
71ae456a
...
@@ -34,18 +34,20 @@ export default async ({ assetPrefix }) => {
...
@@ -34,18 +34,20 @@ export default async ({ assetPrefix }) => {
}
}
evtSource
.
onmessage
=
event
=>
{
evtSource
.
onmessage
=
event
=>
{
const
payload
=
JSON
.
parse
(
event
.
data
)
try
{
if
(
payload
.
invalid
)
{
const
payload
=
JSON
.
parse
(
event
.
data
)
// Payload can be invalid even if the page does not exist.
if
(
payload
.
invalid
)
{
// So, we need to make sure it exists before reloading.
// Payload can be invalid even if the page does not exist.
fetch
(
location
.
href
,
{
// So, we need to make sure it exists before reloading.
credentials
:
'same-origin'
fetch
(
location
.
href
,
{
}).
then
(
pageRes
=>
{
credentials
:
'same-origin'
if
(
pageRes
.
status
===
200
)
{
}).
then
(
pageRes
=>
{
location
.
reload
()
if
(
pageRes
.
status
===
200
)
{
}
location
.
reload
()
})
}
}
})
}
}
catch
(
_
)
{
/* noop */
}
}
}
}
}
...
...
packages/next/server/on-demand-entry-handler.js
View file @
71ae456a
...
@@ -303,6 +303,7 @@ export default function onDemandEntryHandler (devMiddleware, multiCompiler, {
...
@@ -303,6 +303,7 @@ export default function onDemandEntryHandler (devMiddleware, multiCompiler, {
const
runPing
=
()
=>
{
const
runPing
=
()
=>
{
const
data
=
handlePing
(
query
.
page
)
const
data
=
handlePing
(
query
.
page
)
if
(
!
data
)
return
res
.
write
(
'data: '
+
JSON
.
stringify
(
data
)
+
'
\
n
\
n'
)
res
.
write
(
'data: '
+
JSON
.
stringify
(
data
)
+
'
\
n
\
n'
)
}
}
const
pingInterval
=
setInterval
(()
=>
runPing
(),
5000
)
const
pingInterval
=
setInterval
(()
=>
runPing
(),
5000
)
...
...
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