Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow to reload disposed client pages #29815

Merged
merged 5 commits into from
Oct 11, 2021
Merged

allow to reload disposed client pages #29815

merged 5 commits into from
Oct 11, 2021

Conversation

sokra
Copy link
Member

@sokra sokra commented Oct 11, 2021

This allows to reload disposed pages on client-side, which fixes the problem that styling is broken and updates are not visible when returning (with client-side navigations) to an disposed page

timneutkens
timneutkens previously approved these changes Oct 11, 2021
@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@ijjk
Copy link
Member

ijjk commented Oct 11, 2021

Failing test suites

Commit: e40536a

test/integration/route-load-cancel-css/test/index.test.js

  • route cancel via CSS > should cancel slow page loads on re-navigation
Expand output

● route cancel via CSS › should cancel slow page loads on re-navigation

expect(received).toMatch(expected)

Expected pattern: /2/
Received string:  "1"

  28 |
  29 |     const text2 = await browser.elementByCss('#page-text').text()
> 30 |     expect(text2).toMatch(/2/)
     |                   ^
  31 |     expect(await browser.eval('window.routeCancelled')).toBe('yes')
  32 |   })
  33 | }

  at Object.<anonymous> (integration/route-load-cancel-css/test/index.test.js:30:19)

@ijjk
Copy link
Member

ijjk commented Oct 11, 2021

Stats from current PR

Default Build (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary vercel/next.js bugfix/reload-disposed Change
buildDuration 13.8s 13.5s -272ms
buildDurationCached 3.2s 3.2s ⚠️ +50ms
nodeModulesSize 195 MB 195 MB ⚠️ +2.35 kB
Page Load Tests Overall increase ✓
vercel/next.js canary vercel/next.js bugfix/reload-disposed Change
/ failed reqs 0 0
/ total time (seconds) 3.349 3.193 -0.16
/ avg req/sec 746.57 782.93 +36.36
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.762 1.742 -0.02
/error-in-render avg req/sec 1418.46 1435.08 +16.62
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary vercel/next.js bugfix/reload-disposed Change
779.HASH.js gzip 179 B 179 B
framework-HASH.js gzip 42.2 kB 42.2 kB
main-HASH.js gzip 26.9 kB 27 kB ⚠️ +63 B
webpack-HASH.js gzip 1.45 kB 1.45 kB
Overall change 70.8 kB 70.9 kB ⚠️ +63 B
Legacy Client Bundles (polyfills)
vercel/next.js canary vercel/next.js bugfix/reload-disposed Change
polyfills-a4..dd70.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary vercel/next.js bugfix/reload-disposed Change
_app-HASH.js gzip 977 B 977 B
_error-HASH.js gzip 194 B 194 B
amp-HASH.js gzip 311 B 311 B
css-HASH.js gzip 328 B 328 B
dynamic-HASH.js gzip 2.67 kB 2.67 kB
head-HASH.js gzip 351 B 351 B
hooks-HASH.js gzip 918 B 918 B
image-HASH.js gzip 4.12 kB 4.12 kB
index-HASH.js gzip 260 B 260 B
link-HASH.js gzip 1.66 kB 1.66 kB
routerDirect..HASH.js gzip 320 B 320 B
script-HASH.js gzip 386 B 386 B
withRouter-HASH.js gzip 319 B 319 B
bb14e60e810b..30f.css gzip 125 B 125 B
Overall change 12.9 kB 12.9 kB
Client Build Manifests
vercel/next.js canary vercel/next.js bugfix/reload-disposed Change
_buildManifest.js gzip 494 B 494 B
Overall change 494 B 494 B
Rendered Page Sizes Overall decrease ✓
vercel/next.js canary vercel/next.js bugfix/reload-disposed Change
index.html gzip 539 B 539 B
link.html gzip 551 B 550 B -1 B
withRouter.html gzip 533 B 532 B -1 B
Overall change 1.62 kB 1.62 kB -2 B

Diffs

Diff for _buildManifest.js
@@ -1,33 +1,33 @@
 self.__BUILD_MANIFEST = {
   __rewrites: { beforeFiles: [], afterFiles: [], fallback: [] },
-  "/": ["static\u002Fchunks\u002Fpages\u002Findex-b978e60b9d702fa80805.js"],
+  "/": ["static\u002Fchunks\u002Fpages\u002Findex-b90032992c9b33402f59.js"],
   "/_error": [
-    "static\u002Fchunks\u002Fpages\u002F_error-da8666f64dec58f0256c.js"
+    "static\u002Fchunks\u002Fpages\u002F_error-9e631ee4052c01361779.js"
   ],
-  "/amp": ["static\u002Fchunks\u002Fpages\u002Famp-f2a7d08c8a34aef20244.js"],
+  "/amp": ["static\u002Fchunks\u002Fpages\u002Famp-0fa04aed06d71a39bf7a.js"],
   "/css": [
     "static\u002Fcss\u002F59de118426c393f58653.css",
-    "static\u002Fchunks\u002Fpages\u002Fcss-19090fefdf0ea278b474.js"
+    "static\u002Fchunks\u002Fpages\u002Fcss-e5d9641a48cea07ea0d8.js"
   ],
   "/dynamic": [
-    "static\u002Fchunks\u002Fpages\u002Fdynamic-d27debc5ab477ff7a21f.js"
+    "static\u002Fchunks\u002Fpages\u002Fdynamic-3de08c026567a9cee18f.js"
   ],
-  "/head": ["static\u002Fchunks\u002Fpages\u002Fhead-bb121808f5d725b16bf4.js"],
+  "/head": ["static\u002Fchunks\u002Fpages\u002Fhead-bc8abdb676f58cdf601b.js"],
   "/hooks": [
-    "static\u002Fchunks\u002Fpages\u002Fhooks-b247d7d93b59ee105030.js"
+    "static\u002Fchunks\u002Fpages\u002Fhooks-c1f9675770bff0c63be8.js"
   ],
   "/image": [
-    "static\u002Fchunks\u002Fpages\u002Fimage-5e12b7aa334834dd607c.js"
+    "static\u002Fchunks\u002Fpages\u002Fimage-e464a773324a5820a436.js"
   ],
-  "/link": ["static\u002Fchunks\u002Fpages\u002Flink-6c203ee999e47493e19d.js"],
+  "/link": ["static\u002Fchunks\u002Fpages\u002Flink-962a2a330709d57cd073.js"],
   "/routerDirect": [
-    "static\u002Fchunks\u002Fpages\u002FrouterDirect-05d5c820a395af3eca42.js"
+    "static\u002Fchunks\u002Fpages\u002FrouterDirect-0b53270e1ceea2be8c0d.js"
   ],
   "/script": [
-    "static\u002Fchunks\u002Fpages\u002Fscript-9bb97af83a32aad71249.js"
+    "static\u002Fchunks\u002Fpages\u002Fscript-be8bf7491d63e05f4c4d.js"
   ],
   "/withRouter": [
-    "static\u002Fchunks\u002Fpages\u002FwithRouter-a4b2da9a6aabc0207112.js"
+    "static\u002Fchunks\u002Fpages\u002FwithRouter-a12483804a57bd25f921.js"
   ],
   sortedPages: [
     "\u002F",
Diff for _app-HASH.js
@@ -223,6 +223,8 @@
           return __webpack_require__(6871);
         }
       ]);
+      if (false) {
+      }
 
       /***/
     }
Diff for _error-HASH.js
@@ -12,6 +12,8 @@
           return __webpack_require__(7558);
         }
       ]);
+      if (false) {
+      }
 
       /***/
     }
Diff for amp-HASH.js
@@ -54,6 +54,8 @@
           return __webpack_require__(468);
         }
       ]);
+      if (false) {
+      }
 
       /***/
     }
Diff for css-HASH.js
@@ -43,6 +43,8 @@
           return __webpack_require__(8600);
         }
       ]);
+      if (false) {
+      }
 
       /***/
     },
Diff for dynamic-HASH.js
@@ -756,6 +756,8 @@
           return __webpack_require__(2862);
         }
       ]);
+      if (false) {
+      }
 
       /***/
     },
Diff for head-HASH.js
@@ -64,6 +64,8 @@
           return __webpack_require__(8488);
         }
       ]);
+      if (false) {
+      }
 
       /***/
     },
Diff for hooks-HASH.js
@@ -147,6 +147,8 @@
           return __webpack_require__(4925);
         }
       ]);
+      if (false) {
+      }
 
       /***/
     }
Diff for image-HASH.js
@@ -1006,6 +1006,8 @@
           return __webpack_require__(3369);
         }
       ]);
+      if (false) {
+      }
 
       /***/
     },
Diff for index-HASH.js
@@ -36,6 +36,8 @@
           return __webpack_require__(1539);
         }
       ]);
+      if (false) {
+      }
 
       /***/
     }
Diff for link-HASH.js
@@ -455,6 +455,8 @@
           return __webpack_require__(9094);
         }
       ]);
+      if (false) {
+      }
 
       /***/
     },
Diff for routerDirect-HASH.js
@@ -49,6 +49,8 @@
           return __webpack_require__(5426);
         }
       ]);
+      if (false) {
+      }
 
       /***/
     },
Diff for script-HASH.js
@@ -63,6 +63,8 @@
           return __webpack_require__(8529);
         }
       ]);
+      if (false) {
+      }
 
       /***/
     },
Diff for withRouter-HASH.js
@@ -47,6 +47,8 @@
           return __webpack_require__(200);
         }
       ]);
+      if (false) {
+      }
 
       /***/
     },
Diff for main-HASH.js
@@ -2778,18 +2778,24 @@
         var routes = new Map();
 
         function maybeExecuteScript(src) {
-          var prom = loadedScripts.get(src);
+          // With HMR we might need to "reload" scripts when they are
+          // disposed and readded. Executing scripts twice has no functional
+          // differences
+          if (true) {
+            var prom = loadedScripts.get(src);
 
-          if (prom) {
-            return prom;
-          } // Skip executing script if it's already in the DOM:
+            if (prom) {
+              return prom;
+            } // Skip executing script if it's already in the DOM:
 
-          if (document.querySelector('script[src^="'.concat(src, '"]'))) {
-            return Promise.resolve();
-          }
+            if (document.querySelector('script[src^="'.concat(src, '"]'))) {
+              return Promise.resolve();
+            }
 
-          loadedScripts.set(src, (prom = appendScript(src)));
-          return prom;
+            loadedScripts.set(src, (prom = appendScript(src)));
+            return prom;
+          } else {
+          }
         }
 
         function fetchStyleSheet(href) {
@@ -2826,28 +2832,45 @@
             return withFuture(route, entrypoints);
           },
           onEntrypoint: function onEntrypoint(route, execute) {
-            Promise.resolve(execute)
-              .then(function(fn) {
-                return fn();
-              })
-              .then(
-                function(exports) {
-                  return {
-                    component: (exports && exports["default"]) || exports,
-                    exports: exports
-                  };
-                },
-                function(err) {
-                  return {
-                    error: err
-                  };
+            (execute
+              ? Promise.resolve()
+                  .then(function() {
+                    return execute();
+                  })
+                  .then(
+                    function(exports) {
+                      return {
+                        component: (exports && exports["default"]) || exports,
+                        exports: exports
+                      };
+                    },
+                    function(err) {
+                      return {
+                        error: err
+                      };
+                    }
+                  )
+              : Promise.resolve(undefined)
+            ).then(function(input) {
+              var old = entrypoints.get(route);
+
+              if (old && "resolve" in old) {
+                if (input) {
+                  entrypoints.set(route, input);
+                  old.resolve(input);
                 }
-              )
-              .then(function(input) {
-                var old = entrypoints.get(route);
-                entrypoints.set(route, input);
-                if (old && "resolve" in old) old.resolve(input);
-              });
+              } else {
+                if (input) {
+                  entrypoints.set(route, input);
+                } else {
+                  entrypoints["delete"](route);
+                } // when this entrypoint has been resolved before
+                // the route is outdated and we want to invalidate
+                // this cache entry
+
+                routes["delete"](route);
+              }
+            });
           },
           loadRoute: function loadRoute(route, prefetch) {
             var _this = this;
@@ -5927,23 +5950,25 @@
                             );
 
                           case 4:
-                            cachedRouteInfo =
-                              existingRouteInfo &&
-                              "initial" in existingRouteInfo
-                                ? undefined
-                                : existingRouteInfo;
+                            cachedRouteInfo = undefined; // can only use non-initial route info
+                            // cannot reuse route info in development since it can change after HMR
 
-                            if (!cachedRouteInfo) {
-                              _context3.next = 9;
-                              break;
+                            if (
+                              true &&
+                              existingRouteInfo &&
+                              !("initial" in existingRouteInfo)
+                            ) {
+                              cachedRouteInfo = existingRouteInfo;
                             }
 
                             _context3.t0 = cachedRouteInfo;
-                            _context3.next = 12;
-                            break;
 
-                          case 9:
-                            _context3.next = 11;
+                            if (_context3.t0) {
+                              _context3.next = 11;
+                              break;
+                            }
+
+                            _context3.next = 10;
                             return this.fetchComponent(route).then(function(
                               res
                             ) {
@@ -5955,17 +5980,17 @@
                               };
                             });
 
-                          case 11:
+                          case 10:
                             _context3.t0 = _context3.sent;
 
-                          case 12:
+                          case 11:
                             routeInfo = _context3.t0;
                             (Component = routeInfo.Component),
                               (__N_SSG = routeInfo.__N_SSG),
                               (__N_SSP = routeInfo.__N_SSP);
 
                             if (true) {
-                              _context3.next = 18;
+                              _context3.next = 17;
                               break;
                             }
 
@@ -5984,7 +6009,7 @@
                                 _require.isValidElementType);
 
                             if (isValidElementType(Component)) {
-                              _context3.next = 18;
+                              _context3.next = 17;
                               break;
                             }
 
@@ -5995,7 +6020,7 @@
                               )
                             );
 
-                          case 18:
+                          case 17:
                             if (__N_SSG || __N_SSP) {
                               dataHref = this.pageLoader.getDataHref(
                                 (0, _utils).formatWithValidation({
@@ -6008,7 +6033,7 @@
                               );
                             }
 
-                            _context3.next = 21;
+                            _context3.next = 20;
                             return this._getData(function() {
                               return __N_SSG
                                 ? _this2._getStaticData(dataHref)
@@ -6027,14 +6052,14 @@
                                   );
                             });
 
-                          case 21:
+                          case 20:
                             props = _context3.sent;
                             routeInfo.props = props;
                             this.components[route] = routeInfo;
                             return _context3.abrupt("return", routeInfo);
 
-                          case 27:
-                            _context3.prev = 27;
+                          case 26:
+                            _context3.prev = 26;
                             _context3.t1 = _context3["catch"](0);
                             return _context3.abrupt(
                               "return",
@@ -6049,7 +6074,7 @@
                               )
                             );
 
-                          case 30:
+                          case 29:
                           case "end":
                             return _context3.stop();
                         }
@@ -6057,7 +6082,7 @@
                     },
                     _callee3,
                     this,
-                    [[0, 27]]
+                    [[0, 26]]
                   );
                 })
               );
@@ -6327,7 +6352,9 @@
                 /*#__PURE__*/ _regeneratorRuntime.mark(function _callee5(
                   route
                 ) {
-                  var cancelled, cancel, componentResult, error;
+                  var _this4 = this;
+
+                  var cancelled, cancel, handleCancelled, componentResult;
                   return _regeneratorRuntime.wrap(
                     function _callee5$(_context5) {
                       while (1) {
@@ -6339,41 +6366,47 @@
                               cancelled = true;
                             };
 
-                            _context5.next = 4;
-                            return this.pageLoader.loadPage(route);
-
-                          case 4:
-                            componentResult = _context5.sent;
-
-                            if (!cancelled) {
-                              _context5.next = 9;
-                              break;
-                            }
+                            handleCancelled = function handleCancelled() {
+                              if (cancelled) {
+                                var error = new Error(
+                                  'Abort fetching component for route: "'.concat(
+                                    route,
+                                    '"'
+                                  )
+                                );
+                                error.cancelled = true;
+                                throw error;
+                              }
 
-                            error = new Error(
-                              'Abort fetching component for route: "'.concat(
-                                route,
-                                '"'
-                              )
-                            );
-                            error.cancelled = true;
-                            throw error;
+                              if (cancel === _this4.clc) {
+                                _this4.clc = null;
+                              }
+                            };
 
-                          case 9:
-                            if (cancel === this.clc) {
-                              this.clc = null;
-                            }
+                            _context5.prev = 3;
+                            _context5.next = 6;
+                            return this.pageLoader.loadPage(route);
 
+                          case 6:
+                            componentResult = _context5.sent;
+                            handleCancelled();
                             return _context5.abrupt("return", componentResult);
 
                           case 11:
+                            _context5.prev = 11;
+                            _context5.t0 = _context5["catch"](3);
+                            handleCancelled();
+                            throw _context5.t0;
+
+                          case 15:
                           case "end":
                             return _context5.stop();
                         }
                       }
                     },
                     _callee5,
-                    this
+                    this,
+                    [[3, 11]]
                   );
                 })
               );
@@ -6388,7 +6421,7 @@
           {
             key: "_getData",
             value: function _getData(fn) {
-              var _this4 = this;
+              var _this5 = this;
 
               var cancelled = false;
 
@@ -6398,8 +6431,8 @@
 
               this.clc = cancel;
               return fn().then(function(data) {
-                if (cancel === _this4.clc) {
-                  _this4.clc = null;
+                if (cancel === _this5.clc) {
+                  _this5.clc = null;
                 }
 
                 if (cancelled) {
@@ -6415,7 +6448,7 @@
           {
             key: "_getStaticData",
             value: function _getStaticData(dataHref) {
-              var _this5 = this;
+              var _this6 = this;
 
               var _URL = new URL(dataHref, window.location.href),
                 cacheKey = _URL.href;
@@ -6425,7 +6458,7 @@
               }
 
               return fetchNextData(dataHref, this.isSsr).then(function(data) {
-                _this5.sdc[cacheKey] = data;
+                _this6.sdc[cacheKey] = data;
                 return data;
               });
             }
@@ -6433,7 +6466,7 @@
           {
             key: "_getServerData",
             value: function _getServerData(dataHref) {
-              var _this6 = this;
+              var _this7 = this;
 
               var _URL2 = new URL(dataHref, window.location.href),
                 resourceKey = _URL2.href;
@@ -6447,11 +6480,11 @@
                 this.isSsr
               )
                 .then(function(data) {
-                  delete _this6.sdr[resourceKey];
+                  delete _this7.sdr[resourceKey];
                   return data;
                 })
                 ["catch"](function(err) {
-                  delete _this6.sdr[resourceKey];
+                  delete _this7.sdr[resourceKey];
                   throw err;
                 }));
             }
Diff for index.html
@@ -19,15 +19,15 @@
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/main-9f255176843fd9446239.js"
+      src="/_next/static/chunks/main-3099238377d38b88bf6a.js"
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/pages/_app-6329da9dc44135fb5339.js"
+      src="/_next/static/chunks/pages/_app-dd3eb358511b177e9505.js"
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/pages/index-b978e60b9d702fa80805.js"
+      src="/_next/static/chunks/pages/index-b90032992c9b33402f59.js"
       defer=""
     ></script>
     <script src="/_next/static/BUILD_ID/_buildManifest.js" defer=""></script>
Diff for link.html
@@ -19,15 +19,15 @@
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/main-9f255176843fd9446239.js"
+      src="/_next/static/chunks/main-3099238377d38b88bf6a.js"
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/pages/_app-6329da9dc44135fb5339.js"
+      src="/_next/static/chunks/pages/_app-dd3eb358511b177e9505.js"
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/pages/link-6c203ee999e47493e19d.js"
+      src="/_next/static/chunks/pages/link-962a2a330709d57cd073.js"
       defer=""
     ></script>
     <script src="/_next/static/BUILD_ID/_buildManifest.js" defer=""></script>
Diff for withRouter.html
@@ -19,15 +19,15 @@
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/main-9f255176843fd9446239.js"
+      src="/_next/static/chunks/main-3099238377d38b88bf6a.js"
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/pages/_app-6329da9dc44135fb5339.js"
+      src="/_next/static/chunks/pages/_app-dd3eb358511b177e9505.js"
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/pages/withRouter-a4b2da9a6aabc0207112.js"
+      src="/_next/static/chunks/pages/withRouter-a12483804a57bd25f921.js"
       defer=""
     ></script>
     <script src="/_next/static/BUILD_ID/_buildManifest.js" defer=""></script>

Default Build with SWC (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary vercel/next.js bugfix/reload-disposed Change
buildDuration 6.8s 6.9s ⚠️ +80ms
buildDurationCached 3.1s 3.1s ⚠️ +20ms
nodeModulesSize 195 MB 195 MB ⚠️ +2.35 kB
Page Load Tests Overall decrease ⚠️
vercel/next.js canary vercel/next.js bugfix/reload-disposed Change
/ failed reqs 0 0
/ total time (seconds) 3.326 3.439 ⚠️ +0.11
/ avg req/sec 751.76 726.92 ⚠️ -24.84
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.708 1.774 ⚠️ +0.07
/error-in-render avg req/sec 1463.78 1409.47 ⚠️ -54.31
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary vercel/next.js bugfix/reload-disposed Change
675-HASH.js gzip 13.8 kB 13.8 kB
770.HASH.js gzip 178 B 178 B
framework-HASH.js gzip 50.7 kB 50.7 kB
main-HASH.js gzip 35 kB 35 kB ⚠️ +65 B
webpack-HASH.js gzip 1.64 kB 1.64 kB
Overall change 101 kB 101 kB ⚠️ +65 B
Legacy Client Bundles (polyfills)
vercel/next.js canary vercel/next.js bugfix/reload-disposed Change
polyfills-a4..dd70.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary vercel/next.js bugfix/reload-disposed Change
_app-HASH.js gzip 1.33 kB 1.33 kB
_error-HASH.js gzip 180 B 180 B
amp-HASH.js gzip 315 B 315 B
css-HASH.js gzip 331 B 331 B
dynamic-HASH.js gzip 2.79 kB 2.79 kB
head-HASH.js gzip 355 B 355 B
hooks-HASH.js gzip 637 B 637 B
image-HASH.js gzip 555 B 555 B
index-HASH.js gzip 261 B 261 B
link-HASH.js gzip 2.22 kB 2.22 kB
routerDirect..HASH.js gzip 326 B 326 B
script-HASH.js gzip 393 B 393 B
withRouter-HASH.js gzip 322 B 322 B
bb14e60e810b..30f.css gzip 125 B 125 B
Overall change 10.1 kB 10.1 kB
Client Build Manifests
vercel/next.js canary vercel/next.js bugfix/reload-disposed Change
_buildManifest.js gzip 511 B 511 B
Overall change 511 B 511 B
Rendered Page Sizes Overall decrease ✓
vercel/next.js canary vercel/next.js bugfix/reload-disposed Change
index.html gzip 538 B 538 B
link.html gzip 553 B 552 B -1 B
withRouter.html gzip 533 B 533 B
Overall change 1.62 kB 1.62 kB -1 B

Diffs

Diff for _buildManifest.js
@@ -1,34 +1,34 @@
 self.__BUILD_MANIFEST = {
   __rewrites: { beforeFiles: [], afterFiles: [], fallback: [] },
-  "/": ["static\u002Fchunks\u002Fpages\u002Findex-ab3eacf0db76ede5c34e.js"],
+  "/": ["static\u002Fchunks\u002Fpages\u002Findex-62b6d914325f07931441.js"],
   "/_error": [
-    "static\u002Fchunks\u002Fpages\u002F_error-9e1a6d936e12ddc840ba.js"
+    "static\u002Fchunks\u002Fpages\u002F_error-5465a03ec8001cf52192.js"
   ],
-  "/amp": ["static\u002Fchunks\u002Fpages\u002Famp-8bc8c2d84cd1ee3af177.js"],
+  "/amp": ["static\u002Fchunks\u002Fpages\u002Famp-76b1d1cad2fa670990e7.js"],
   "/css": [
     "static\u002Fcss\u002F59de118426c393f58653.css",
-    "static\u002Fchunks\u002Fpages\u002Fcss-b933e198cac52ec08478.js"
+    "static\u002Fchunks\u002Fpages\u002Fcss-971c9d7976475fd8ecd9.js"
   ],
   "/dynamic": [
-    "static\u002Fchunks\u002Fpages\u002Fdynamic-6d23c90f2595f3596b95.js"
+    "static\u002Fchunks\u002Fpages\u002Fdynamic-b28ea4260e0900058882.js"
   ],
-  "/head": ["static\u002Fchunks\u002Fpages\u002Fhead-7bb5bee479e60e9cbbf6.js"],
+  "/head": ["static\u002Fchunks\u002Fpages\u002Fhead-ac328e77dde10022dc84.js"],
   "/hooks": [
-    "static\u002Fchunks\u002Fpages\u002Fhooks-57657d9807f56726f7b7.js"
+    "static\u002Fchunks\u002Fpages\u002Fhooks-7fa8f6299881aeef4d92.js"
   ],
   "/image": [
     "static\u002Fchunks\u002F675-e36478c6435f19ec761d.js",
-    "static\u002Fchunks\u002Fpages\u002Fimage-7adb256b36a03439bd79.js"
+    "static\u002Fchunks\u002Fpages\u002Fimage-24dfc0766459a85ca885.js"
   ],
-  "/link": ["static\u002Fchunks\u002Fpages\u002Flink-88e6441e88b717c1f4fe.js"],
+  "/link": ["static\u002Fchunks\u002Fpages\u002Flink-d5bdd3af9bbbd881abda.js"],
   "/routerDirect": [
-    "static\u002Fchunks\u002Fpages\u002FrouterDirect-afb5e539aab48677ee82.js"
+    "static\u002Fchunks\u002Fpages\u002FrouterDirect-0c3a69578ed98df5d7be.js"
   ],
   "/script": [
-    "static\u002Fchunks\u002Fpages\u002Fscript-3bd2b6d599dff985e742.js"
+    "static\u002Fchunks\u002Fpages\u002Fscript-11366980389598d0fd29.js"
   ],
   "/withRouter": [
-    "static\u002Fchunks\u002Fpages\u002FwithRouter-42d971b6e1d5b9681097.js"
+    "static\u002Fchunks\u002Fpages\u002FwithRouter-7faf010ab7dedd43f8cc.js"
   ],
   sortedPages: [
     "\u002F",
Diff for _app-HASH.js
@@ -12,6 +12,8 @@
           return __webpack_require__(4596);
         }
       ]);
+      if (false) {
+      }
 
       /***/
     },
Diff for _error-HASH.js
@@ -12,6 +12,8 @@
           return __webpack_require__(5509);
         }
       ]);
+      if (false) {
+      }
 
       /***/
     }
Diff for amp-HASH.js
@@ -22,6 +22,8 @@
           return __webpack_require__(7659);
         }
       ]);
+      if (false) {
+      }
 
       /***/
     },
Diff for css-HASH.js
@@ -12,6 +12,8 @@
           return __webpack_require__(9436);
         }
       ]);
+      if (false) {
+      }
 
       /***/
     },
Diff for dynamic-HASH.js
@@ -12,6 +12,8 @@
           return __webpack_require__(7202);
         }
       ]);
+      if (false) {
+      }
 
       /***/
     },
Diff for head-HASH.js
@@ -12,6 +12,8 @@
           return __webpack_require__(223);
         }
       ]);
+      if (false) {
+      }
 
       /***/
     },
Diff for hooks-HASH.js
@@ -12,6 +12,8 @@
           return __webpack_require__(522);
         }
       ]);
+      if (false) {
+      }
 
       /***/
     },
Diff for image-HASH.js
@@ -12,6 +12,8 @@
           return __webpack_require__(1532);
         }
       ]);
+      if (false) {
+      }
 
       /***/
     },
Diff for index-HASH.js
@@ -12,6 +12,8 @@
           return __webpack_require__(5006);
         }
       ]);
+      if (false) {
+      }
 
       /***/
     },
Diff for link-HASH.js
@@ -12,6 +12,8 @@
           return __webpack_require__(1437);
         }
       ]);
+      if (false) {
+      }
 
       /***/
     },
Diff for routerDirect-HASH.js
@@ -12,6 +12,8 @@
           return __webpack_require__(3791);
         }
       ]);
+      if (false) {
+      }
 
       /***/
     },
Diff for script-HASH.js
@@ -12,6 +12,8 @@
           return __webpack_require__(3172);
         }
       ]);
+      if (false) {
+      }
 
       /***/
     },
Diff for withRouter-HASH.js
@@ -12,6 +12,8 @@
           return __webpack_require__(3650);
         }
       ]);
+      if (false) {
+      }
 
       /***/
     },
Diff for main-HASH.js
@@ -2057,16 +2057,22 @@
       }
       function createRouteLoader(assetPrefix) {
         var maybeExecuteScript = function maybeExecuteScript(src) {
-          var prom = loadedScripts.get(src);
-          if (prom) {
+          // With HMR we might need to "reload" scripts when they are
+          // disposed and readded. Executing scripts twice has no functional
+          // differences
+          if (true) {
+            var prom = loadedScripts.get(src);
+            if (prom) {
+              return prom;
+            }
+            // Skip executing script if it's already in the DOM:
+            if (document.querySelector('script[src^="'.concat(src, '"]'))) {
+              return Promise.resolve();
+            }
+            loadedScripts.set(src, (prom = appendScript(src)));
             return prom;
+          } else {
           }
-          // Skip executing script if it's already in the DOM:
-          if (document.querySelector('script[src^="'.concat(src, '"]'))) {
-            return Promise.resolve();
-          }
-          loadedScripts.set(src, (prom = appendScript(src)));
-          return prom;
         };
         var fetchStyleSheet = function fetchStyleSheet(href) {
           var prom = styleSheets.get(href);
@@ -2102,28 +2108,44 @@
             return withFuture(route, entrypoints);
           },
           onEntrypoint: function(route, execute) {
-            Promise.resolve(execute)
-              .then(function(fn) {
-                return fn();
-              })
-              .then(
-                function(exports) {
-                  return {
-                    component: (exports && exports.default) || exports,
-                    exports: exports
-                  };
-                },
-                function(err) {
-                  return {
-                    error: err
-                  };
+            (execute
+              ? Promise.resolve()
+                  .then(function() {
+                    return execute();
+                  })
+                  .then(
+                    function(exports) {
+                      return {
+                        component: (exports && exports.default) || exports,
+                        exports: exports
+                      };
+                    },
+                    function(err) {
+                      return {
+                        error: err
+                      };
+                    }
+                  )
+              : Promise.resolve(undefined)
+            ).then(function(input) {
+              var old = entrypoints.get(route);
+              if (old && "resolve" in old) {
+                if (input) {
+                  entrypoints.set(route, input);
+                  old.resolve(input);
                 }
-              )
-              .then(function(input) {
-                var old = entrypoints.get(route);
-                entrypoints.set(route, input);
-                if (old && "resolve" in old) old.resolve(input);
-              });
+              } else {
+                if (input) {
+                  entrypoints.set(route, input);
+                } else {
+                  entrypoints.delete(route);
+                }
+                // when this entrypoint has been resolved before
+                // the route is outdated and we want to invalidate
+                // this cache entry
+                routes.delete(route);
+              }
+            });
           },
           loadRoute: function(route, prefetch) {
             var _this = this;
@@ -5091,20 +5113,22 @@
                               }
                               return _ctx.abrupt("return", existingRouteInfo);
                             case 5:
-                              cachedRouteInfo =
+                              cachedRouteInfo = undefined;
+                              // can only use non-initial route info
+                              // cannot reuse route info in development since it can change after HMR
+                              if (
+                                true &&
                                 existingRouteInfo &&
-                                "initial" in existingRouteInfo
-                                  ? undefined
-                                  : existingRouteInfo;
-                              if (!cachedRouteInfo) {
-                                _ctx.next = 10;
-                                break;
+                                !("initial" in existingRouteInfo)
+                              ) {
+                                cachedRouteInfo = existingRouteInfo;
                               }
                               _ctx.t0 = cachedRouteInfo;
-                              _ctx.next = 13;
-                              break;
-                            case 10:
-                              _ctx.next = 12;
+                              if (_ctx.t0) {
+                                _ctx.next = 12;
+                                break;
+                              }
+                              _ctx.next = 11;
                               return this.fetchComponent(route).then(function(
                                 res
                               ) {
@@ -5115,9 +5139,9 @@
                                   __N_SSP: res.mod.__N_SSP
                                 };
                               });
-                            case 12:
+                            case 11:
                               _ctx.t0 = _ctx.sent;
-                            case 13:
+                            case 12:
                               routeInfo = _ctx.t0;
                               var ref;
                               (ref = routeInfo),
@@ -5126,7 +5150,7 @@
                                 (__N_SSP = ref.__N_SSP),
                                 ref;
                               if (true) {
-                                _ctx.next = 19;
+                                _ctx.next = 18;
                                 break;
                               }
                               var ref1;
@@ -5144,7 +5168,7 @@
                                 (isValidElementType = ref1.isValidElementType),
                                 ref1;
                               if (isValidElementType(Component)) {
-                                _ctx.next = 19;
+                                _ctx.next = 18;
                                 break;
                               }
                               throw new Error(
@@ -5153,7 +5177,7 @@
                                   '"'
                                 )
                               );
-                            case 19:
+                            case 18:
                               if (__N_SSG || __N_SSP) {
                                 dataHref = this.pageLoader.getDataHref(
                                   (0, _utils).formatWithValidation({
@@ -5165,7 +5189,7 @@
                                   this.locale
                                 );
                               }
-                              _ctx.next = 23;
+                              _ctx.next = 22;
                               return this._getData(function() {
                                 return __N_SSG
                                   ? _this._getStaticData(dataHref)
@@ -5180,13 +5204,13 @@
                                       defaultLocale: _this.defaultLocale
                                     });
                               });
-                            case 23:
+                            case 22:
                               props = _ctx.sent;
                               routeInfo.props = props;
                               this.components[route] = routeInfo;
                               return _ctx.abrupt("return", routeInfo);
-                            case 29:
-                              _ctx.prev = 29;
+                            case 28:
+                              _ctx.prev = 28;
                               _ctx.t1 = _ctx["catch"](0);
                               return _ctx.abrupt(
                                 "return",
@@ -5200,14 +5224,14 @@
                                   routeProps
                                 )
                               );
-                            case 32:
+                            case 31:
                             case "end":
                               return _ctx.stop();
                           }
                       },
                       _callee,
                       this,
-                      [[0, 29]]
+                      [[0, 28]]
                     );
                   })
                   .bind(this)
@@ -5436,44 +5460,56 @@
               return _asyncToGenerator(
                 _regeneratorRuntime.default
                   .mark(function _callee() {
-                    var cancelled, cancel, componentResult, error;
+                    var _this,
+                      cancelled,
+                      cancel,
+                      handleCancelled,
+                      componentResult;
                     return _regeneratorRuntime.default.wrap(
                       function _callee$(_ctx) {
                         while (1)
                           switch ((_ctx.prev = _ctx.next)) {
                             case 0:
+                              _this = this;
                               cancelled = false;
                               cancel = this.clc = function() {
                                 cancelled = true;
                               };
-                              _ctx.next = 4;
+                              handleCancelled = function() {
+                                if (cancelled) {
+                                  var error = new Error(
+                                    'Abort fetching component for route: "'.concat(
+                                      route,
+                                      '"'
+                                    )
+                                  );
+                                  error.cancelled = true;
+                                  throw error;
+                                }
+                                if (cancel === _this.clc) {
+                                  _this.clc = null;
+                                }
+                              };
+                              _ctx.prev = 4;
+                              _ctx.next = 7;
                               return this.pageLoader.loadPage(route);
-                            case 4:
+                            case 7:
                               componentResult = _ctx.sent;
-                              if (!cancelled) {
-                                _ctx.next = 9;
-                                break;
-                              }
-                              error = new Error(
-                                'Abort fetching component for route: "'.concat(
-                                  route,
-                                  '"'
-                                )
-                              );
-                              error.cancelled = true;
-                              throw error;
-                            case 9:
-                              if (cancel === this.clc) {
-                                this.clc = null;
-                              }
+                              handleCancelled();
                               return _ctx.abrupt("return", componentResult);
-                            case 11:
+                            case 12:
+                              _ctx.prev = 12;
+                              _ctx.t0 = _ctx["catch"](4);
+                              handleCancelled();
+                              throw _ctx.t0;
+                            case 16:
                             case "end":
                               return _ctx.stop();
                           }
                       },
                       _callee,
-                      this
+                      this,
+                      [[4, 12]]
                     );
                   })
                   .bind(this)
Diff for index.html
@@ -19,15 +19,15 @@
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/main-3509cb58ba25b0dec1a1.js"
+      src="/_next/static/chunks/main-f96eb284fb29c8575709.js"
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/pages/_app-a40329fa2faeee9f0899.js"
+      src="/_next/static/chunks/pages/_app-109074558afb747dbe12.js"
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/pages/index-ab3eacf0db76ede5c34e.js"
+      src="/_next/static/chunks/pages/index-62b6d914325f07931441.js"
       defer=""
     ></script>
     <script src="/_next/static/BUILD_ID/_buildManifest.js" defer=""></script>
Diff for link.html
@@ -19,15 +19,15 @@
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/main-3509cb58ba25b0dec1a1.js"
+      src="/_next/static/chunks/main-f96eb284fb29c8575709.js"
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/pages/_app-a40329fa2faeee9f0899.js"
+      src="/_next/static/chunks/pages/_app-109074558afb747dbe12.js"
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/pages/link-88e6441e88b717c1f4fe.js"
+      src="/_next/static/chunks/pages/link-d5bdd3af9bbbd881abda.js"
       defer=""
     ></script>
     <script src="/_next/static/BUILD_ID/_buildManifest.js" defer=""></script>
Diff for withRouter.html
@@ -19,15 +19,15 @@
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/main-3509cb58ba25b0dec1a1.js"
+      src="/_next/static/chunks/main-f96eb284fb29c8575709.js"
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/pages/_app-a40329fa2faeee9f0899.js"
+      src="/_next/static/chunks/pages/_app-109074558afb747dbe12.js"
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/pages/withRouter-42d971b6e1d5b9681097.js"
+      src="/_next/static/chunks/pages/withRouter-7faf010ab7dedd43f8cc.js"
       defer=""
     ></script>
     <script src="/_next/static/BUILD_ID/_buildManifest.js" defer=""></script>
Commit: 91ecd53

@sokra sokra merged commit e679f5b into canary Oct 11, 2021
@sokra sokra deleted the bugfix/reload-disposed branch October 11, 2021 18:36
@vercel vercel locked as resolved and limited conversation to collaborators Jan 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants