What is the cause of "Loading initial props cancelled" in Nextjs?

Viewed 2139

In our application we have a few different users (~20 according to Plumbr) per day who get the following exception

Error: Loading initial props cancelled

We have determined that the error comes from the _getData<T> method in router.ts but haven't been able to figure out the cause nor reproduce it. We have tried adding throttling using Chrome dev tools and doing multiple actions that call router in quick succession but no dice.

What causes the error?

1 Answers

Gregor has a seed of truth. This may occur due to the users stopping the page load before it is fully loaded.

Also, this may happen when your DB Query Promise is not resolved yet and your router will already try to route.push you onto another page. As a solution, try Timeout for 200-400 miliseconds delay on on router.push.

The same with "route is cancelled". If a route load is cancelled (for example, by clicking two links rapidly in succession), routeChangeError will fire. And the passed err will contain a cancelled property set to true.

Related