Skip to content

Commit

Permalink
Make comment more verbose for racing
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Feb 5, 2020
1 parent fc21a4b commit 70546aa
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/next/next-server/lib/router/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,10 @@ export default class Router implements BaseRouter {

if ((routeInfo as any).dataRes) {
const dataRes = (routeInfo as any).dataRes as Promise<RouteInfo>
// race loading state timeout with data response

// to prevent a flash of the fallback page we delay showing it for
// 110ms and race the timeout with the data response. If the data
// beats the timeout we skip showing the fallback
Promise.race([
new Promise(resolve => setTimeout(() => resolve(false), 110)),
dataRes,
Expand Down

0 comments on commit 70546aa

Please sign in to comment.