question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Stale sessions error out during navigate if a deployment occured after the page first loads

See original GitHub issue

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I’m using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

It’s common for tabs to be left open for long and people people revisit these tabs again after a few days. Unfortunately Docusaurus hasn’t handled this case very well if a new deployment occured during a session and the user tries to navigate on stale sessions. Each Docusaurus page has a corresponding chunk and the stale versions of the website will still be referring to the old chunks but they don’t exist anymore in the new deployment. As a result, you see a progress bar at the top which never completes.

Reproducible demo

No response

Steps to reproduce

  1. Open a Docusaurus site in a tab
  2. Change some contents and push to the site
  3. Go back to the tab and try to navigate by clicking on links or whatever

Expected behavior

Can navigate pages even on stale sessions.

Actual behavior

See that the spinner never completes. There’ll be an error in the browser console

Uncaught (in promise) ChunkLoadError: Loading chunk 484 failed.
(error: https://www.techinterviewhandbook.org/assets/js/b44c9e68.bc980405.js)
    at n.f.j (runtime~main.fc544bd8.js:1:8609)
    at runtime~main.fc544bd8.js:1:1418
    at Array.reduce (<anonymous>)
    at n.e (runtime~main.fc544bd8.js:1:1383)
    at f.b44c9e68 (main.a2ce0572.js:2:18693)
    at d (main.a2ce0572.js:2:365638)
    at main.a2ce0572.js:2:365913
    at Array.forEach (<anonymous>)
    at f (main.a2ce0572.js:2:365886)
    at h (main.a2ce0572.js:2:366532)

This is because the chunk names aren’t stable and change after a new deployment if the build changes.

I think a fix would be to perform a hard refresh if an error was encountered during navigation, e.g. a chunk cannot be loaded.

Another good fix to make would be to make the chunk names more stable and don’t change if the contents don’t change (I always thought that should be the default), at least the “damage” will be contained to the pages which have really changed. This doesn’t eliminate the need for the hard reload though.

Your environment

Self-service

  • I’d be willing to fix this bug myself.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Josh-Cenacommented, Jun 11, 2022

I think you can try here:

https://github.com/facebook/docusaurus/blob/ec8230b7ba395b6b317b3e4bc3441e3d9b116651/packages/docusaurus/src/client/PendingNavigation.tsx#L68-L73

During preload, PendingNavigation itself is already receiving the new location as props, but it’s passing the old location down to the route element, so I’m not sure whether you need to use location.reload or location.assign to force navigation.

1reaction
Josh-Cenacommented, Jun 11, 2022

Aw, that’s interesting…

So do we just do a location.reload() when catching a preload error?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot Firepower Threat Defense Policy Deployments
This document provides a high-level overview of the Policy Deployment process on FTD and as well as basic troubleshooting techniques.
Read more >
Code splitting causes chunks to fail to load after new ...
When I deploy a new version of my app the users will usually get an error if a user still has the page...
Read more >
Troubleshoot on-premises deployments
A time-out error occurs when a Service Fabric cluster is created. Run Test-D365FOConfiguration.ps1 as noted in the "Set up a standalone Service ...
Read more >
React Router DOM: How to handle routing in web apps
When the location changes because of a navigation action, the child component (in this case <App> ) is re-rendered. Most of the time,...
Read more >
Environments and deployments - GitLab Docs
If you want to use the environment URL in GitLab, you would have to update it manually. To address this problem, you can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found