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
8c6550c5
Commit
8c6550c5
authored
Jun 23, 2017
by
Arunoda Susiripala
Committed by
GitHub
Jun 23, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a potential race condition in router when doing prefetching. (#2317)
parent
213d7a82
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
8 deletions
+10
-8
page-loader.js
lib/page-loader.js
+10
-8
No files found.
lib/page-loader.js
View file @
8c6550c5
...
...
@@ -30,17 +30,10 @@ export default class PageLoader {
loadPage
(
route
)
{
route
=
this
.
normalizeRoute
(
route
)
const
cachedPage
=
this
.
pageCache
[
route
]
if
(
cachedPage
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
cachedPage
.
error
)
return
reject
(
cachedPage
.
error
)
return
resolve
(
cachedPage
.
page
)
})
}
return
new
Promise
((
resolve
,
reject
)
=>
{
const
fire
=
({
error
,
page
})
=>
{
this
.
pageRegisterEvents
.
off
(
route
,
fire
)
delete
this
.
loadingRoutes
[
route
]
if
(
error
)
{
reject
(
error
)
...
...
@@ -49,6 +42,15 @@ export default class PageLoader {
}
}
// If there's a cached version of the page, let's use it.
const
cachedPage
=
this
.
pageCache
[
route
]
if
(
cachedPage
)
{
const
{
error
,
page
}
=
cachedPage
error
?
reject
(
error
)
:
resolve
(
page
)
return
}
// Register a listener to get the page
this
.
pageRegisterEvents
.
on
(
route
,
fire
)
// If the page is loading via SSR, we need to wait for it
...
...
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