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

Only prefetch Link if router is in context #19857

Merged
merged 8 commits into from
Jan 6, 2021
Merged

Conversation

damusnet
Copy link
Contributor

@damusnet damusnet commented Dec 4, 2020

Fixes #16864

The router can be missing in a test environment when trying to render a Link component. This PR bails out of router.prefetch() when router is missing.

The alternative is for users to mock next/link or to mock the router and wrap their test components.

Please let me know any feedback.

@ijjk ijjk added the type: next label Dec 4, 2020
@vercel vercel bot temporarily deployed to Preview December 4, 2020 22:35 Inactive
@ijjk
Copy link
Member

ijjk commented Dec 4, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary damusnet/next.js patch-1 Change
buildDuration 10.3s 10.3s -10ms
nodeModulesSize 82.4 MB 82.4 MB ⚠️ +67 B
Page Load Tests Overall increase ✓
vercel/next.js canary damusnet/next.js patch-1 Change
/ failed reqs 0 0
/ total time (seconds) 2.53 2.546 ⚠️ +0.02
/ avg req/sec 988.12 981.9 ⚠️ -6.22
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.416 1.363 -0.05
/error-in-render avg req/sec 1765.77 1834 +68.23
Client Bundles (main, webpack, commons)
vercel/next.js canary damusnet/next.js patch-1 Change
677f882d2ed8..34b9.js gzip 12.8 kB 12.8 kB
framework.HASH.js gzip 39 kB 39 kB
main-f501b4a..c42e.js gzip 6.56 kB 6.56 kB
webpack-e067..f178.js gzip 751 B 751 B
Overall change 59 kB 59 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary damusnet/next.js patch-1 Change
polyfills-4b..e242.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary damusnet/next.js patch-1 Change
_app-7231d4b..5856.js gzip 1.28 kB 1.28 kB
_error-01375..90b6.js gzip 3.69 kB 3.69 kB
hooks-d4591d..e7c2.js gzip 887 B 887 B
index-17468f..5d83.js gzip 227 B 227 B
link-db223d9..dbd7.js gzip 1.61 kB 1.61 kB
routerDirect..924c.js gzip 284 B 284 B
withRouter-7..c13d.js gzip 284 B 284 B
Overall change 8.27 kB 8.27 kB
Client Build Manifests Overall decrease ✓
vercel/next.js canary damusnet/next.js patch-1 Change
_buildManifest.js gzip 322 B 321 B -1 B
Overall change 322 B 321 B -1 B
Rendered Page Sizes
vercel/next.js canary damusnet/next.js patch-1 Change
index.html gzip 614 B 614 B
link.html gzip 621 B 621 B
withRouter.html gzip 608 B 608 B
Overall change 1.84 kB 1.84 kB

Diffs

Diff for _buildManifest.js
@@ -7,7 +7,7 @@ self.__BUILD_MANIFEST = {
   "/hooks": [
     "static\u002Fchunks\u002Fpages\u002Fhooks-bdd2cad07648acf22380.js"
   ],
-  "/link": ["static\u002Fchunks\u002Fpages\u002Flink-00f0f71a76f57326f2aa.js"],
+  "/link": ["static\u002Fchunks\u002Fpages\u002Flink-aa22eb3ee024b433cd56.js"],
   "/routerDirect": [
     "static\u002Fchunks\u002Fpages\u002FrouterDirect-2e9bfd441bd88cd3382e.js"
   ],
Diff for link-00f0f71..57326f2aa.js
@@ -85,6 +85,7 @@ _N_E = (window["webpackJsonp_N_E"] = window["webpackJsonp_N_E"] || []).push([
       var prefetched = {};
 
       function prefetch(router, href, as, options) {
+        if (!router) return;
         if (false) {
         }
         if (!(0, _router.isLocalURL)(href)) return; // Prefetch the JSON page if asked (only in the client)
Diff for link.html
@@ -32,7 +32,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/pages/link-00f0f71a76f57326f2aa.js"
+      href="/_next/static/chunks/pages/link-aa22eb3ee024b433cd56.js"
       as="script"
     />
   </head>
@@ -78,7 +78,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/pages/link-00f0f71a76f57326f2aa.js"
+      src="/_next/static/chunks/pages/link-aa22eb3ee024b433cd56.js"
       async=""
     ></script>
     <script src="/_next/static/BUILD_ID/_buildManifest.js" async=""></script>

Serverless Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary damusnet/next.js patch-1 Change
buildDuration 12.5s 12.3s -213ms
nodeModulesSize 82.4 MB 82.4 MB ⚠️ +67 B
Client Bundles (main, webpack, commons)
vercel/next.js canary damusnet/next.js patch-1 Change
677f882d2ed8..34b9.js gzip 12.8 kB 12.8 kB
framework.HASH.js gzip 39 kB 39 kB
main-f501b4a..c42e.js gzip 6.56 kB 6.56 kB
webpack-e067..f178.js gzip 751 B 751 B
Overall change 59 kB 59 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary damusnet/next.js patch-1 Change
polyfills-4b..e242.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary damusnet/next.js patch-1 Change
_app-7231d4b..5856.js gzip 1.28 kB 1.28 kB
_error-01375..90b6.js gzip 3.69 kB 3.69 kB
hooks-d4591d..e7c2.js gzip 887 B 887 B
index-17468f..5d83.js gzip 227 B 227 B
link-db223d9..dbd7.js gzip 1.61 kB N/A N/A
routerDirect..924c.js gzip 284 B 284 B
withRouter-7..c13d.js gzip 284 B 284 B
link-a082e4c..7984.js gzip N/A 1.61 kB N/A
Overall change 8.27 kB 8.27 kB
Client Build Manifests Overall decrease ✓
vercel/next.js canary damusnet/next.js patch-1 Change
_buildManifest.js gzip 322 B 321 B -1 B
Overall change 322 B 321 B -1 B
Serverless bundles Overall increase ⚠️
vercel/next.js canary damusnet/next.js patch-1 Change
_error.js 1 MB 1 MB
404.html 2.67 kB 2.67 kB
hooks.html 1.92 kB 1.92 kB
index.js 1 MB 1 MB
link.js 1.06 MB 1.06 MB ⚠️ +23 B
routerDirect.js 1.05 MB 1.05 MB
withRouter.js 1.05 MB 1.05 MB
Overall change 5.16 MB 5.16 MB ⚠️ +23 B
Commit: a9244d2

@damusnet damusnet marked this pull request as ready for review December 4, 2020 22:49
@@ -40,6 +40,7 @@ function prefetch(
as: string,
options?: PrefetchOptions
): void {
if (!router) return
if (typeof window === 'undefined') return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do something like this instead to save some bytes

Suggested change
if (typeof window === 'undefined') return
if (typeof window === 'undefined' || !router) return

Copy link
Member

@timneutkens timneutkens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change needs an integration test

@vercel vercel bot temporarily deployed to Preview December 7, 2020 17:48 Inactive
@damusnet
Copy link
Contributor Author

damusnet commented Dec 7, 2020

Hi @timneutkens, thanks for looking at this and for your feedback.

I made the suggested change, however I'd need some help for the integration test. Can you please point me to the correct file, or an example to re-use?

This patch changes no behavior for app/prod code, is only meant to allow test environments to mount <Link /> outside of a router context.

@ijjk
Copy link
Member

ijjk commented Dec 7, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary damusnet/next.js patch-1 Change
buildDuration 10.5s 10.5s ⚠️ +13ms
nodeModulesSize 82.5 MB 82.5 MB ⚠️ +38 B
Page Load Tests Overall increase ✓
vercel/next.js canary damusnet/next.js patch-1 Change
/ failed reqs 0 0
/ total time (seconds) 2.651 2.674 ⚠️ +0.02
/ avg req/sec 943.01 934.98 ⚠️ -8.03
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.606 1.539 -0.07
/error-in-render avg req/sec 1556.54 1624.04 +67.5
Client Bundles (main, webpack, commons)
vercel/next.js canary damusnet/next.js patch-1 Change
677f882d2ed8..34b9.js gzip 12.8 kB 12.8 kB
framework.HASH.js gzip 39 kB 39 kB
main-f501b4a..c42e.js gzip 6.56 kB 6.56 kB
webpack-e067..f178.js gzip 751 B 751 B
Overall change 59 kB 59 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary damusnet/next.js patch-1 Change
polyfills-4b..e242.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary damusnet/next.js patch-1 Change
_app-7231d4b..5856.js gzip 1.28 kB 1.28 kB
_error-01375..90b6.js gzip 3.69 kB 3.69 kB
hooks-d4591d..e7c2.js gzip 887 B 887 B
index-17468f..5d83.js gzip 227 B 227 B
link-db223d9..dbd7.js gzip 1.61 kB 1.61 kB
routerDirect..924c.js gzip 284 B 284 B
withRouter-7..c13d.js gzip 284 B 284 B
Overall change 8.27 kB 8.27 kB
Client Build Manifests
vercel/next.js canary damusnet/next.js patch-1 Change
_buildManifest.js gzip 322 B 322 B
Overall change 322 B 322 B
Rendered Page Sizes
vercel/next.js canary damusnet/next.js patch-1 Change
index.html gzip 614 B 614 B
link.html gzip 621 B 621 B
withRouter.html gzip 608 B 608 B
Overall change 1.84 kB 1.84 kB

Diffs

Diff for _buildManifest.js
@@ -7,7 +7,7 @@ self.__BUILD_MANIFEST = {
   "/hooks": [
     "static\u002Fchunks\u002Fpages\u002Fhooks-bdd2cad07648acf22380.js"
   ],
-  "/link": ["static\u002Fchunks\u002Fpages\u002Flink-00f0f71a76f57326f2aa.js"],
+  "/link": ["static\u002Fchunks\u002Fpages\u002Flink-47e9d30705009340f173.js"],
   "/routerDirect": [
     "static\u002Fchunks\u002Fpages\u002FrouterDirect-2e9bfd441bd88cd3382e.js"
   ],
Diff for link-00f0f71..57326f2aa.js
@@ -85,8 +85,7 @@ _N_E = (window["webpackJsonp_N_E"] = window["webpackJsonp_N_E"] || []).push([
       var prefetched = {};
 
       function prefetch(router, href, as, options) {
-        if (false) {
-        }
+        if (false || !router) return;
         if (!(0, _router.isLocalURL)(href)) return; // Prefetch the JSON page if asked (only in the client)
         // We need to handle a prefetch error here since we may be
         // loading with priority which can reject but we don't
Diff for link.html
@@ -32,7 +32,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/pages/link-00f0f71a76f57326f2aa.js"
+      href="/_next/static/chunks/pages/link-47e9d30705009340f173.js"
       as="script"
     />
   </head>
@@ -78,7 +78,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/pages/link-00f0f71a76f57326f2aa.js"
+      src="/_next/static/chunks/pages/link-47e9d30705009340f173.js"
       async=""
     ></script>
     <script src="/_next/static/BUILD_ID/_buildManifest.js" async=""></script>

Serverless Mode
General Overall increase ⚠️
vercel/next.js canary damusnet/next.js patch-1 Change
buildDuration 12s 12.3s ⚠️ +285ms
nodeModulesSize 82.5 MB 82.5 MB ⚠️ +38 B
Client Bundles (main, webpack, commons)
vercel/next.js canary damusnet/next.js patch-1 Change
677f882d2ed8..34b9.js gzip 12.8 kB 12.8 kB
framework.HASH.js gzip 39 kB 39 kB
main-f501b4a..c42e.js gzip 6.56 kB 6.56 kB
webpack-e067..f178.js gzip 751 B 751 B
Overall change 59 kB 59 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary damusnet/next.js patch-1 Change
polyfills-4b..e242.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary damusnet/next.js patch-1 Change
_app-7231d4b..5856.js gzip 1.28 kB 1.28 kB
_error-01375..90b6.js gzip 3.69 kB 3.69 kB
hooks-d4591d..e7c2.js gzip 887 B 887 B
index-17468f..5d83.js gzip 227 B 227 B
link-db223d9..dbd7.js gzip 1.61 kB N/A N/A
routerDirect..924c.js gzip 284 B 284 B
withRouter-7..c13d.js gzip 284 B 284 B
link-2fe9ad9..b3b7.js gzip N/A 1.61 kB N/A
Overall change 8.27 kB 8.27 kB
Client Build Manifests
vercel/next.js canary damusnet/next.js patch-1 Change
_buildManifest.js gzip 322 B 322 B
Overall change 322 B 322 B
Serverless bundles
vercel/next.js canary damusnet/next.js patch-1 Change
_error.js 1 MB 1 MB
404.html 2.67 kB 2.67 kB
hooks.html 1.92 kB 1.92 kB
index.js 1 MB 1 MB
link.js 1.06 MB 1.06 MB
routerDirect.js 1.05 MB 1.05 MB
withRouter.js 1.05 MB 1.05 MB
Overall change 5.16 MB 5.16 MB
Commit: 19802a7

@vercel vercel bot temporarily deployed to Preview December 10, 2020 17:28 Inactive
@ijjk
Copy link
Member

ijjk commented Dec 10, 2020

Stats from current PR

Default Server Mode (Decrease detected ✓)
General Overall increase ⚠️
vercel/next.js canary damusnet/next.js patch-1 Change
buildDuration 9.9s 9.7s -139ms
nodeModulesSize 82.5 MB 82.5 MB ⚠️ +38 B
Page Load Tests Overall decrease ⚠️
vercel/next.js canary damusnet/next.js patch-1 Change
/ failed reqs 0 0
/ total time (seconds) 2.366 2.439 ⚠️ +0.07
/ avg req/sec 1056.79 1024.84 ⚠️ -31.95
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.235 1.255 ⚠️ +0.02
/error-in-render avg req/sec 2024.48 1991.35 ⚠️ -33.13
Client Bundles (main, webpack, commons)
vercel/next.js canary damusnet/next.js patch-1 Change
677f882d2ed8..34b9.js gzip 12.8 kB 12.8 kB
framework.HASH.js gzip 39 kB 39 kB
main-3e8cb31..cddc.js gzip 6.56 kB 6.56 kB
webpack-e067..f178.js gzip 751 B 751 B
Overall change 59 kB 59 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary damusnet/next.js patch-1 Change
polyfills-4b..e242.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary damusnet/next.js patch-1 Change
_app-7231d4b..5856.js gzip 1.28 kB 1.28 kB
_error-01375..90b6.js gzip 3.69 kB 3.69 kB
hooks-d4591d..e7c2.js gzip 887 B 887 B
index-17468f..5d83.js gzip 227 B 227 B
link-db223d9..dbd7.js gzip 1.61 kB 1.61 kB
routerDirect..fd29.js gzip 303 B 303 B
withRouter-b..76ae.js gzip 302 B 302 B
Overall change 8.31 kB 8.31 kB
Client Build Manifests Overall increase ⚠️
vercel/next.js canary damusnet/next.js patch-1 Change
_buildManifest.js gzip 322 B 323 B ⚠️ +1 B
Overall change 322 B 323 B ⚠️ +1 B
Rendered Page Sizes Overall increase ⚠️
vercel/next.js canary damusnet/next.js patch-1 Change
index.html gzip 614 B 614 B
link.html gzip 620 B 621 B ⚠️ +1 B
withRouter.html gzip 608 B 608 B
Overall change 1.84 kB 1.84 kB ⚠️ +1 B

Diffs

Diff for _buildManifest.js
@@ -7,7 +7,7 @@ self.__BUILD_MANIFEST = {
   "/hooks": [
     "static\u002Fchunks\u002Fpages\u002Fhooks-bdd2cad07648acf22380.js"
   ],
-  "/link": ["static\u002Fchunks\u002Fpages\u002Flink-00f0f71a76f57326f2aa.js"],
+  "/link": ["static\u002Fchunks\u002Fpages\u002Flink-47e9d30705009340f173.js"],
   "/routerDirect": [
     "static\u002Fchunks\u002Fpages\u002FrouterDirect-6f408582ce776dfa74d5.js"
   ],
Diff for link-00f0f71..57326f2aa.js
@@ -85,8 +85,7 @@ _N_E = (window["webpackJsonp_N_E"] = window["webpackJsonp_N_E"] || []).push([
       var prefetched = {};
 
       function prefetch(router, href, as, options) {
-        if (false) {
-        }
+        if (false || !router) return;
         if (!(0, _router.isLocalURL)(href)) return; // Prefetch the JSON page if asked (only in the client)
         // We need to handle a prefetch error here since we may be
         // loading with priority which can reject but we don't
Diff for link.html
@@ -32,7 +32,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/pages/link-00f0f71a76f57326f2aa.js"
+      href="/_next/static/chunks/pages/link-47e9d30705009340f173.js"
       as="script"
     />
   </head>
@@ -78,7 +78,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/pages/link-00f0f71a76f57326f2aa.js"
+      src="/_next/static/chunks/pages/link-47e9d30705009340f173.js"
       async=""
     ></script>
     <script src="/_next/static/BUILD_ID/_buildManifest.js" async=""></script>

Serverless Mode
General Overall increase ⚠️
vercel/next.js canary damusnet/next.js patch-1 Change
buildDuration 11.7s 11.7s -7ms
nodeModulesSize 82.5 MB 82.5 MB ⚠️ +38 B
Client Bundles (main, webpack, commons)
vercel/next.js canary damusnet/next.js patch-1 Change
677f882d2ed8..34b9.js gzip 12.8 kB 12.8 kB
framework.HASH.js gzip 39 kB 39 kB
main-3e8cb31..cddc.js gzip 6.56 kB 6.56 kB
webpack-e067..f178.js gzip 751 B 751 B
Overall change 59 kB 59 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary damusnet/next.js patch-1 Change
polyfills-4b..e242.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary damusnet/next.js patch-1 Change
_app-7231d4b..5856.js gzip 1.28 kB 1.28 kB
_error-01375..90b6.js gzip 3.69 kB 3.69 kB
hooks-d4591d..e7c2.js gzip 887 B 887 B
index-17468f..5d83.js gzip 227 B 227 B
link-db223d9..dbd7.js gzip 1.61 kB N/A N/A
routerDirect..fd29.js gzip 303 B 303 B
withRouter-b..76ae.js gzip 302 B 302 B
link-2fe9ad9..b3b7.js gzip N/A 1.61 kB N/A
Overall change 8.31 kB 8.31 kB
Client Build Manifests Overall increase ⚠️
vercel/next.js canary damusnet/next.js patch-1 Change
_buildManifest.js gzip 322 B 323 B ⚠️ +1 B
Overall change 322 B 323 B ⚠️ +1 B
Serverless bundles
vercel/next.js canary damusnet/next.js patch-1 Change
_error.js 1 MB 1 MB
404.html 2.67 kB 2.67 kB
hooks.html 1.92 kB 1.92 kB
index.js 1 MB 1 MB
link.js 1.06 MB 1.06 MB
routerDirect.js 1.05 MB 1.05 MB
withRouter.js 1.05 MB 1.05 MB
Overall change 5.16 MB 5.16 MB
Commit: 004a4bf

@vercel vercel bot temporarily deployed to Preview December 10, 2020 19:04 Inactive
@damusnet
Copy link
Contributor Author

damusnet commented Dec 10, 2020

@timneutkens I don't know if this counts as an integration test ; it feels more like a unit test to me, but I couldn't find any example of chrome webdriver that does not launch the Next.js app.

Please let me know if this works for you, or if I should move it to the unit test folder, or if I need to go in a completely different direction.

Before: After:
image image

@damusnet damusnet requested a review from timneutkens December 10, 2020 19:07
@ijjk
Copy link
Member

ijjk commented Dec 10, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary damusnet/next.js patch-1 Change
buildDuration 8.4s 8.3s -47ms
nodeModulesSize 82.5 MB 82.5 MB ⚠️ +38 B
Page Load Tests Overall increase ✓
vercel/next.js canary damusnet/next.js patch-1 Change
/ failed reqs 0 0
/ total time (seconds) 2.001 2.01 ⚠️ +0.01
/ avg req/sec 1249.27 1243.86 ⚠️ -5.41
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.083 1.06 -0.02
/error-in-render avg req/sec 2308.43 2358.43 +50
Client Bundles (main, webpack, commons)
vercel/next.js canary damusnet/next.js patch-1 Change
677f882d2ed8..34b9.js gzip 12.8 kB 12.8 kB
framework.HASH.js gzip 39 kB 39 kB
main-3e8cb31..cddc.js gzip 6.56 kB 6.56 kB
webpack-e067..f178.js gzip 751 B 751 B
Overall change 59 kB 59 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary damusnet/next.js patch-1 Change
polyfills-4b..e242.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary damusnet/next.js patch-1 Change
_app-7231d4b..5856.js gzip 1.28 kB 1.28 kB
_error-01375..90b6.js gzip 3.69 kB 3.69 kB
hooks-d4591d..e7c2.js gzip 887 B 887 B
index-17468f..5d83.js gzip 227 B 227 B
link-db223d9..dbd7.js gzip 1.61 kB 1.61 kB
routerDirect..fd29.js gzip 303 B 303 B
withRouter-b..76ae.js gzip 302 B 302 B
Overall change 8.31 kB 8.31 kB
Client Build Manifests Overall increase ⚠️
vercel/next.js canary damusnet/next.js patch-1 Change
_buildManifest.js gzip 322 B 323 B ⚠️ +1 B
Overall change 322 B 323 B ⚠️ +1 B
Rendered Page Sizes Overall increase ⚠️
vercel/next.js canary damusnet/next.js patch-1 Change
index.html gzip 614 B 614 B
link.html gzip 620 B 621 B ⚠️ +1 B
withRouter.html gzip 608 B 608 B
Overall change 1.84 kB 1.84 kB ⚠️ +1 B

Diffs

Diff for _buildManifest.js
@@ -7,7 +7,7 @@ self.__BUILD_MANIFEST = {
   "/hooks": [
     "static\u002Fchunks\u002Fpages\u002Fhooks-bdd2cad07648acf22380.js"
   ],
-  "/link": ["static\u002Fchunks\u002Fpages\u002Flink-00f0f71a76f57326f2aa.js"],
+  "/link": ["static\u002Fchunks\u002Fpages\u002Flink-47e9d30705009340f173.js"],
   "/routerDirect": [
     "static\u002Fchunks\u002Fpages\u002FrouterDirect-6f408582ce776dfa74d5.js"
   ],
Diff for link-00f0f71..57326f2aa.js
@@ -85,8 +85,7 @@ _N_E = (window["webpackJsonp_N_E"] = window["webpackJsonp_N_E"] || []).push([
       var prefetched = {};
 
       function prefetch(router, href, as, options) {
-        if (false) {
-        }
+        if (false || !router) return;
         if (!(0, _router.isLocalURL)(href)) return; // Prefetch the JSON page if asked (only in the client)
         // We need to handle a prefetch error here since we may be
         // loading with priority which can reject but we don't
Diff for link.html
@@ -32,7 +32,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/pages/link-00f0f71a76f57326f2aa.js"
+      href="/_next/static/chunks/pages/link-47e9d30705009340f173.js"
       as="script"
     />
   </head>
@@ -78,7 +78,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/pages/link-00f0f71a76f57326f2aa.js"
+      src="/_next/static/chunks/pages/link-47e9d30705009340f173.js"
       async=""
     ></script>
     <script src="/_next/static/BUILD_ID/_buildManifest.js" async=""></script>

Serverless Mode
General Overall increase ⚠️
vercel/next.js canary damusnet/next.js patch-1 Change
buildDuration 9.7s 10.1s ⚠️ +346ms
nodeModulesSize 82.5 MB 82.5 MB ⚠️ +38 B
Client Bundles (main, webpack, commons)
vercel/next.js canary damusnet/next.js patch-1 Change
677f882d2ed8..34b9.js gzip 12.8 kB 12.8 kB
framework.HASH.js gzip 39 kB 39 kB
main-3e8cb31..cddc.js gzip 6.56 kB 6.56 kB
webpack-e067..f178.js gzip 751 B 751 B
Overall change 59 kB 59 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary damusnet/next.js patch-1 Change
polyfills-4b..e242.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary damusnet/next.js patch-1 Change
_app-7231d4b..5856.js gzip 1.28 kB 1.28 kB
_error-01375..90b6.js gzip 3.69 kB 3.69 kB
hooks-d4591d..e7c2.js gzip 887 B 887 B
index-17468f..5d83.js gzip 227 B 227 B
link-db223d9..dbd7.js gzip 1.61 kB N/A N/A
routerDirect..fd29.js gzip 303 B 303 B
withRouter-b..76ae.js gzip 302 B 302 B
link-2fe9ad9..b3b7.js gzip N/A 1.61 kB N/A
Overall change 8.31 kB 8.31 kB
Client Build Manifests Overall increase ⚠️
vercel/next.js canary damusnet/next.js patch-1 Change
_buildManifest.js gzip 322 B 323 B ⚠️ +1 B
Overall change 322 B 323 B ⚠️ +1 B
Serverless bundles
vercel/next.js canary damusnet/next.js patch-1 Change
_error.js 1 MB 1 MB
404.html 2.67 kB 2.67 kB
hooks.html 1.92 kB 1.92 kB
index.js 1 MB 1 MB
link.js 1.06 MB 1.06 MB
routerDirect.js 1.05 MB 1.05 MB
withRouter.js 1.05 MB 1.05 MB
Overall change 5.16 MB 5.16 MB
Commit: fc5e454

@damusnet
Copy link
Contributor Author

@timneutkens Hi, sorry to insist ; any chance you could review this MR again please? Cheers

@vercel vercel bot temporarily deployed to Preview December 21, 2020 20:40 Inactive
@ijjk
Copy link
Member

ijjk commented Dec 21, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary damusnet/next.js patch-1 Change
buildDuration 10.7s 10.5s -150ms
nodeModulesSize 82.6 MB 82.6 MB ⚠️ +38 B
Page Load Tests Overall increase ✓
vercel/next.js canary damusnet/next.js patch-1 Change
/ failed reqs 0 0
/ total time (seconds) 2.19 2.186 0
/ avg req/sec 1141.44 1143.87 +2.43
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.421 1.368 -0.05
/error-in-render avg req/sec 1759.32 1827.44 +68.12
Client Bundles (main, webpack, commons)
vercel/next.js canary damusnet/next.js patch-1 Change
677f882d2ed8..5e70.js gzip 12.8 kB 12.8 kB
framework.HASH.js gzip 39 kB 39 kB
main-72193d1..1356.js gzip 6.56 kB 6.56 kB
webpack-95c2..e870.js gzip 751 B 751 B
Overall change 59 kB 59 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary damusnet/next.js patch-1 Change
polyfills-d3..23f6.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary damusnet/next.js patch-1 Change
_app-0d19cb6..5497.js gzip 1.28 kB 1.28 kB
_error-85785..a9f3.js gzip 3.44 kB 3.44 kB
hooks-42456f..0c06.js gzip 887 B 887 B
index-8081ce..e44f.js gzip 227 B 227 B
link-0ab9f83..fa00.js gzip 1.61 kB 1.61 kB
routerDirect..c3d8.js gzip 303 B 303 B
withRouter-0..a68e.js gzip 302 B 302 B
Overall change 8.05 kB 8.05 kB
Client Build Manifests
vercel/next.js canary damusnet/next.js patch-1 Change
_buildManifest.js gzip 323 B 323 B
Overall change 323 B 323 B
Rendered Page Sizes Overall increase ⚠️
vercel/next.js canary damusnet/next.js patch-1 Change
index.html gzip 613 B 613 B
link.html gzip 618 B 619 B ⚠️ +1 B
withRouter.html gzip 607 B 607 B
Overall change 1.84 kB 1.84 kB ⚠️ +1 B

Diffs

Diff for _buildManifest.js
@@ -7,7 +7,7 @@ self.__BUILD_MANIFEST = {
   "/hooks": [
     "static\u002Fchunks\u002Fpages\u002Fhooks-bdd2cad07648acf22380.js"
   ],
-  "/link": ["static\u002Fchunks\u002Fpages\u002Flink-00f0f71a76f57326f2aa.js"],
+  "/link": ["static\u002Fchunks\u002Fpages\u002Flink-47e9d30705009340f173.js"],
   "/routerDirect": [
     "static\u002Fchunks\u002Fpages\u002FrouterDirect-6f408582ce776dfa74d5.js"
   ],
Diff for link-00f0f71..57326f2aa.js
@@ -85,8 +85,7 @@ _N_E = (window["webpackJsonp_N_E"] = window["webpackJsonp_N_E"] || []).push([
       var prefetched = {};
 
       function prefetch(router, href, as, options) {
-        if (false) {
-        }
+        if (false || !router) return;
         if (!(0, _router.isLocalURL)(href)) return; // Prefetch the JSON page if asked (only in the client)
         // We need to handle a prefetch error here since we may be
         // loading with priority which can reject but we don't
Diff for link.html
@@ -32,7 +32,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/pages/link-00f0f71a76f57326f2aa.js"
+      href="/_next/static/chunks/pages/link-47e9d30705009340f173.js"
       as="script"
     />
   </head>
@@ -78,7 +78,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/pages/link-00f0f71a76f57326f2aa.js"
+      src="/_next/static/chunks/pages/link-47e9d30705009340f173.js"
       async=""
     ></script>
     <script src="/_next/static/BUILD_ID/_buildManifest.js" async=""></script>

Serverless Mode
General Overall increase ⚠️
vercel/next.js canary damusnet/next.js patch-1 Change
buildDuration 12.7s 12.7s ⚠️ +30ms
nodeModulesSize 82.6 MB 82.6 MB ⚠️ +38 B
Client Bundles (main, webpack, commons)
vercel/next.js canary damusnet/next.js patch-1 Change
677f882d2ed8..5e70.js gzip 12.8 kB 12.8 kB
framework.HASH.js gzip 39 kB 39 kB
main-72193d1..1356.js gzip 6.56 kB 6.56 kB
webpack-95c2..e870.js gzip 751 B 751 B
Overall change 59 kB 59 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary damusnet/next.js patch-1 Change
polyfills-d3..23f6.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary damusnet/next.js patch-1 Change
_app-0d19cb6..5497.js gzip 1.28 kB 1.28 kB
_error-85785..a9f3.js gzip 3.44 kB 3.44 kB
hooks-42456f..0c06.js gzip 887 B 887 B
index-8081ce..e44f.js gzip 227 B 227 B
link-0ab9f83..fa00.js gzip 1.61 kB N/A N/A
routerDirect..c3d8.js gzip 303 B 303 B
withRouter-0..a68e.js gzip 302 B 302 B
link-87a9325..7837.js gzip N/A 1.61 kB N/A
Overall change 8.05 kB 8.05 kB
Client Build Manifests
vercel/next.js canary damusnet/next.js patch-1 Change
_buildManifest.js gzip 323 B 323 B
Overall change 323 B 323 B
Serverless bundles
vercel/next.js canary damusnet/next.js patch-1 Change
_error.js 1 MB 1 MB
404.html 2.67 kB 2.67 kB
hooks.html 1.92 kB 1.92 kB
index.js 1 MB 1 MB
link.js 1.06 MB 1.06 MB
routerDirect.js 1.05 MB 1.05 MB
withRouter.js 1.05 MB 1.05 MB
Overall change 5.16 MB 5.16 MB
Commit: ac1aa10

@timneutkens
Copy link
Member

Thanks! The test looks fine 👍

@kodiakhq kodiakhq bot merged commit 55afe80 into vercel:canary Jan 6, 2021
@damusnet damusnet deleted the patch-1 branch January 6, 2021 16:37
@vercel vercel locked as resolved and limited conversation to collaborators Jan 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot read property 'prefetch' and 'push' of null
4 participants