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

Ensure query for static pages with rewrites is updated correctly #24189

Merged
merged 8 commits into from
Apr 18, 2021

Conversation

ijjk
Copy link
Member

@ijjk ijjk commented Apr 18, 2021

This updates the query refreshing on the client to also refresh when rewrites are used and the page is static since additional query values can be provided from rewrites that are relied on client-side. An additional test has been added in the custom-routes suite to ensure this is working correctly.

Bug

  • Related issues linked using fixes #number
  • Integration tests added

Fixes: #23490
Fixes: #22931
Fixes: #21062

@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@ijjk
Copy link
Member Author

ijjk commented Apr 18, 2021

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
buildDuration 16.7s 16.6s -126ms
buildDurationCached 5.2s 5.3s ⚠️ +99ms
nodeModulesSize 46.2 MB 46.3 MB ⚠️ +1.2 kB
Page Load Tests Overall decrease ⚠️
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
/ failed reqs 0 0
/ total time (seconds) 2.93 3.13 ⚠️ +0.2
/ avg req/sec 853.27 798.6 ⚠️ -54.67
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.725 1.8 ⚠️ +0.07
/error-in-render avg req/sec 1449.19 1388.58 ⚠️ -60.61
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
597-HASH.js gzip 13.3 kB 13.3 kB
778-HASH.js gzip 7.05 kB 7.08 kB ⚠️ +38 B
framework-HASH.js gzip 39.3 kB 39.3 kB
main-HASH.js gzip 151 B 151 B
webpack-HASH.js gzip 993 B 993 B
Overall change 60.8 kB 60.8 kB ⚠️ +38 B
Legacy Client Bundles (polyfills)
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
polyfills-HASH.js gzip 31.1 kB 31.1 kB
Overall change 31.1 kB 31.1 kB
Client Pages
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
_app-HASH.js gzip 1.3 kB 1.3 kB
_error-HASH.js gzip 3.68 kB 3.68 kB
amp-HASH.js gzip 558 B 558 B
hooks-HASH.js gzip 924 B 924 B
index-HASH.js gzip 243 B 243 B
link-HASH.js gzip 1.66 kB 1.66 kB
routerDirect..HASH.js gzip 336 B 336 B
withRouter-HASH.js gzip 334 B 334 B
Overall change 9.03 kB 9.03 kB
Client Build Manifests
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
_buildManifest.js gzip 349 B 349 B
Overall change 349 B 349 B
Rendered Page Sizes Overall increase ⚠️
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
index.html gzip 611 B 610 B -1 B
link.html gzip 616 B 616 B
withRouter.html gzip 604 B 606 B ⚠️ +2 B
Overall change 1.83 kB 1.83 kB ⚠️ +1 B

Diffs

Diff for 597-HASH.js
@@ -1918,7 +1918,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
           this.isReady = !!(
             self.__NEXT_DATA__.gssp ||
             self.__NEXT_DATA__.gip ||
-            (!autoExportDynamic && !self.location.search)
+            (!autoExportDynamic && !self.location.search && !false)
           );
           this.isPreview = !!isPreview;
           this.isLocaleDomain = false;
Diff for 778-HASH.js
@@ -520,12 +520,24 @@
               // - if it is a client-side skeleton (fallback render)
 
               if (
-                router.isSsr &&
+                router.isSsr && // We don't update for 404 requests as this can modify
+                // the asPath unexpectedly e.g. adding basePath when
+                // it wasn't originally present
+                page !== "/404" &&
+                !(
+                  page === "/_error" &&
+                  hydrateProps &&
+                  hydrateProps.pageProps &&
+                  hydrateProps.pageProps.statusCode === 404
+                ) &&
                 (isFallback ||
                   (data.nextExport &&
                     ((0, _isDynamic.isDynamicRoute)(router.pathname) ||
-                      location.search)) ||
-                  (hydrateProps && hydrateProps.__N_SSG && location.search))
+                      location.search ||
+                      false)) ||
+                  (hydrateProps &&
+                    hydrateProps.__N_SSG &&
+                    (location.search || false)))
               ) {
                 // update query on mount for exported pages
                 router.replace(
Diff for index.html
@@ -7,7 +7,7 @@
     <noscript data-n-css=""></noscript>
     <link
       rel="preload"
-      href="/_next/static/chunks/webpack-15295a88fc613ba5cbc8.js"
+      href="/_next/static/chunks/webpack-a7a5a48c965095318776.js"
       as="script"
     />
     <link
@@ -17,12 +17,12 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/597-3f45794671bbb399288d.js"
+      href="/_next/static/chunks/597-787e5f8c20ace23d20b2.js"
       as="script"
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/778-5b575716c0bcacfbf1eb.js"
+      href="/_next/static/chunks/778-9a3bad1797977da2192b.js"
       as="script"
     />
     <link
@@ -58,7 +58,7 @@
       src="/_next/static/chunks/polyfills-8683bd742a84c1edd48c.js"
     ></script>
     <script
-      src="/_next/static/chunks/webpack-15295a88fc613ba5cbc8.js"
+      src="/_next/static/chunks/webpack-a7a5a48c965095318776.js"
       async=""
     ></script>
     <script
@@ -66,11 +66,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/597-3f45794671bbb399288d.js"
+      src="/_next/static/chunks/597-787e5f8c20ace23d20b2.js"
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/778-5b575716c0bcacfbf1eb.js"
+      src="/_next/static/chunks/778-9a3bad1797977da2192b.js"
       async=""
     ></script>
     <script
Diff for link.html
@@ -7,7 +7,7 @@
     <noscript data-n-css=""></noscript>
     <link
       rel="preload"
-      href="/_next/static/chunks/webpack-15295a88fc613ba5cbc8.js"
+      href="/_next/static/chunks/webpack-a7a5a48c965095318776.js"
       as="script"
     />
     <link
@@ -17,12 +17,12 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/597-3f45794671bbb399288d.js"
+      href="/_next/static/chunks/597-787e5f8c20ace23d20b2.js"
       as="script"
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/778-5b575716c0bcacfbf1eb.js"
+      href="/_next/static/chunks/778-9a3bad1797977da2192b.js"
       as="script"
     />
     <link
@@ -63,7 +63,7 @@
       src="/_next/static/chunks/polyfills-8683bd742a84c1edd48c.js"
     ></script>
     <script
-      src="/_next/static/chunks/webpack-15295a88fc613ba5cbc8.js"
+      src="/_next/static/chunks/webpack-a7a5a48c965095318776.js"
       async=""
     ></script>
     <script
@@ -71,11 +71,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/597-3f45794671bbb399288d.js"
+      src="/_next/static/chunks/597-787e5f8c20ace23d20b2.js"
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/778-5b575716c0bcacfbf1eb.js"
+      src="/_next/static/chunks/778-9a3bad1797977da2192b.js"
       async=""
     ></script>
     <script
Diff for withRouter.html
@@ -7,7 +7,7 @@
     <noscript data-n-css=""></noscript>
     <link
       rel="preload"
-      href="/_next/static/chunks/webpack-15295a88fc613ba5cbc8.js"
+      href="/_next/static/chunks/webpack-a7a5a48c965095318776.js"
       as="script"
     />
     <link
@@ -17,12 +17,12 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/597-3f45794671bbb399288d.js"
+      href="/_next/static/chunks/597-787e5f8c20ace23d20b2.js"
       as="script"
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/778-5b575716c0bcacfbf1eb.js"
+      href="/_next/static/chunks/778-9a3bad1797977da2192b.js"
       as="script"
     />
     <link
@@ -58,7 +58,7 @@
       src="/_next/static/chunks/polyfills-8683bd742a84c1edd48c.js"
     ></script>
     <script
-      src="/_next/static/chunks/webpack-15295a88fc613ba5cbc8.js"
+      src="/_next/static/chunks/webpack-a7a5a48c965095318776.js"
       async=""
     ></script>
     <script
@@ -66,11 +66,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/597-3f45794671bbb399288d.js"
+      src="/_next/static/chunks/597-787e5f8c20ace23d20b2.js"
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/778-5b575716c0bcacfbf1eb.js"
+      src="/_next/static/chunks/778-9a3bad1797977da2192b.js"
       async=""
     ></script>
     <script

Serverless Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
buildDuration 21.2s 21.5s ⚠️ +314ms
buildDurationCached 7.7s 7.5s -158ms
nodeModulesSize 46.2 MB 46.3 MB ⚠️ +1.2 kB
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
597-HASH.js gzip 13.3 kB 13.3 kB
778-HASH.js gzip 7.05 kB 7.08 kB ⚠️ +38 B
framework-HASH.js gzip 39.3 kB 39.3 kB
main-HASH.js gzip 151 B 151 B
webpack-HASH.js gzip 993 B 993 B
Overall change 60.8 kB 60.8 kB ⚠️ +38 B
Legacy Client Bundles (polyfills)
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
polyfills-HASH.js gzip 31.1 kB 31.1 kB
Overall change 31.1 kB 31.1 kB
Client Pages
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
_app-HASH.js gzip 1.3 kB 1.3 kB
_error-HASH.js gzip 3.68 kB 3.68 kB
amp-HASH.js gzip 558 B 558 B
hooks-HASH.js gzip 924 B 924 B
index-HASH.js gzip 243 B 243 B
link-HASH.js gzip 1.66 kB 1.66 kB
routerDirect..HASH.js gzip 336 B 336 B
withRouter-HASH.js gzip 334 B 334 B
Overall change 9.03 kB 9.03 kB
Client Build Manifests
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
_buildManifest.js gzip 349 B 349 B
Overall change 349 B 349 B
Serverless bundles Overall increase ⚠️
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
_error.js 1.39 MB 1.39 MB
404.html 2.76 kB 2.76 kB
500.html 2.75 kB 2.75 kB
amp.amp.html 10.7 kB 10.7 kB
amp.html 1.96 kB 1.96 kB
hooks.html 2.01 kB 2.01 kB
index.js 1.39 MB 1.39 MB
link.js 1.45 MB 1.45 MB ⚠️ +10 B
routerDirect.js 1.44 MB 1.44 MB ⚠️ +10 B
withRouter.js 1.44 MB 1.44 MB ⚠️ +12 B
Overall change 7.15 MB 7.15 MB ⚠️ +32 B

Webpack 4 Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
buildDuration 14.4s 14.1s -243ms
buildDurationCached 6s 5.8s -218ms
nodeModulesSize 46.2 MB 46.3 MB ⚠️ +1.2 kB
Page Load Tests Overall decrease ⚠️
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
/ failed reqs 0 0
/ total time (seconds) 2.989 3.07 ⚠️ +0.08
/ avg req/sec 836.45 814.24 ⚠️ -22.21
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.77 1.752 -0.02
/error-in-render avg req/sec 1412.51 1427.16 +14.65
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
677f882d2ed8..HASH.js gzip 13.4 kB 13.4 kB
framework.HASH.js gzip 39 kB 39 kB
main-HASH.js gzip 7.12 kB 7.16 kB ⚠️ +40 B
webpack-HASH.js gzip 751 B 751 B
Overall change 60.2 kB 60.2 kB ⚠️ +40 B
Legacy Client Bundles (polyfills)
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
polyfills-HASH.js gzip 31.3 kB 31.3 kB
Overall change 31.3 kB 31.3 kB
Client Pages
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
_app-HASH.js gzip 1.28 kB 1.28 kB
_error-HASH.js gzip 3.71 kB 3.71 kB
amp-HASH.js gzip 536 B 536 B
hooks-HASH.js gzip 888 B 888 B
index-HASH.js gzip 227 B 227 B
link-HASH.js gzip 1.64 kB 1.64 kB
routerDirect..HASH.js gzip 303 B 303 B
withRouter-HASH.js gzip 302 B 302 B
Overall change 8.89 kB 8.89 kB
Client Build Manifests
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
_buildManifest.js gzip 371 B 371 B
Overall change 371 B 371 B
Rendered Page Sizes Overall decrease ✓
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
index.html gzip 613 B 612 B -1 B
link.html gzip 620 B 619 B -1 B
withRouter.html gzip 607 B 608 B ⚠️ +1 B
Overall change 1.84 kB 1.84 kB -1 B

Diffs

Diff for 677f882d2ed8..c4df.HASH.js
@@ -1754,7 +1754,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
           this.isReady = !!(
             self.__NEXT_DATA__.gssp ||
             self.__NEXT_DATA__.gip ||
-            (!autoExportDynamic && !self.location.search)
+            (!autoExportDynamic && !self.location.search && !false)
           );
           this.isPreview = !!isPreview;
           this.isLocaleDomain = false;
Diff for main-HASH.js
@@ -522,12 +522,24 @@ _N_E = (window["webpackJsonp_N_E"] = window["webpackJsonp_N_E"] || []).push([
               // - if it is a client-side skeleton (fallback render)
 
               if (
-                router.isSsr &&
+                router.isSsr && // We don't update for 404 requests as this can modify
+                // the asPath unexpectedly e.g. adding basePath when
+                // it wasn't originally present
+                page !== "/404" &&
+                !(
+                  page === "/_error" &&
+                  hydrateProps &&
+                  hydrateProps.pageProps &&
+                  hydrateProps.pageProps.statusCode === 404
+                ) &&
                 (isFallback ||
                   (data.nextExport &&
                     ((0, _isDynamic.isDynamicRoute)(router.pathname) ||
-                      location.search)) ||
-                  (hydrateProps && hydrateProps.__N_SSG && location.search))
+                      location.search ||
+                      false)) ||
+                  (hydrateProps &&
+                    hydrateProps.__N_SSG &&
+                    (location.search || false)))
               ) {
                 // update query on mount for exported pages
                 router.replace(
Diff for index.html
@@ -17,12 +17,12 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.9435f13b64c68ee0afbc.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.09f58d2592a57435f49b.js"
       as="script"
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/main-68872973a2f90e2eea94.js"
+      href="/_next/static/chunks/main-cd8309a5d2810f21d24d.js"
       as="script"
     />
     <link
@@ -61,11 +61,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.9435f13b64c68ee0afbc.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.09f58d2592a57435f49b.js"
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/main-68872973a2f90e2eea94.js"
+      src="/_next/static/chunks/main-cd8309a5d2810f21d24d.js"
       async=""
     ></script>
     <script
Diff for link.html
@@ -17,12 +17,12 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.9435f13b64c68ee0afbc.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.09f58d2592a57435f49b.js"
       as="script"
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/main-68872973a2f90e2eea94.js"
+      href="/_next/static/chunks/main-cd8309a5d2810f21d24d.js"
       as="script"
     />
     <link
@@ -66,11 +66,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.9435f13b64c68ee0afbc.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.09f58d2592a57435f49b.js"
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/main-68872973a2f90e2eea94.js"
+      src="/_next/static/chunks/main-cd8309a5d2810f21d24d.js"
       async=""
     ></script>
     <script
Diff for withRouter.html
@@ -17,12 +17,12 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.9435f13b64c68ee0afbc.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.09f58d2592a57435f49b.js"
       as="script"
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/main-68872973a2f90e2eea94.js"
+      href="/_next/static/chunks/main-cd8309a5d2810f21d24d.js"
       as="script"
     />
     <link
@@ -61,11 +61,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.9435f13b64c68ee0afbc.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.09f58d2592a57435f49b.js"
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/main-68872973a2f90e2eea94.js"
+      src="/_next/static/chunks/main-cd8309a5d2810f21d24d.js"
       async=""
     ></script>
     <script
Commit: 49edbc2

@ijjk ijjk marked this pull request as ready for review April 18, 2021 03:55
@ijjk
Copy link
Member Author

ijjk commented Apr 18, 2021

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
buildDuration 15.4s 15.6s ⚠️ +194ms
buildDurationCached 4.7s 4.6s -8ms
nodeModulesSize 46.3 MB 46.3 MB ⚠️ +1.2 kB
Page Load Tests Overall increase ✓
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
/ failed reqs 0 0
/ total time (seconds) 2.783 2.81 ⚠️ +0.03
/ avg req/sec 898.26 889.73 ⚠️ -8.53
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.604 1.551 -0.05
/error-in-render avg req/sec 1558.7 1612.23 +53.53
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
597-HASH.js gzip 13.3 kB 13.3 kB
778-HASH.js gzip 7.05 kB 7.08 kB ⚠️ +38 B
framework-HASH.js gzip 39.3 kB 39.3 kB
main-HASH.js gzip 151 B 151 B
webpack-HASH.js gzip 993 B 993 B
Overall change 60.8 kB 60.8 kB ⚠️ +38 B
Legacy Client Bundles (polyfills)
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
polyfills-HASH.js gzip 31.1 kB 31.1 kB
Overall change 31.1 kB 31.1 kB
Client Pages
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
_app-HASH.js gzip 1.3 kB 1.3 kB
_error-HASH.js gzip 3.68 kB 3.68 kB
amp-HASH.js gzip 558 B 558 B
hooks-HASH.js gzip 924 B 924 B
index-HASH.js gzip 243 B 243 B
link-HASH.js gzip 1.66 kB 1.66 kB
routerDirect..HASH.js gzip 336 B 336 B
withRouter-HASH.js gzip 334 B 334 B
Overall change 9.03 kB 9.03 kB
Client Build Manifests
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
_buildManifest.js gzip 349 B 349 B
Overall change 349 B 349 B
Rendered Page Sizes Overall increase ⚠️
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
index.html gzip 609 B 610 B ⚠️ +1 B
link.html gzip 615 B 616 B ⚠️ +1 B
withRouter.html gzip 603 B 605 B ⚠️ +2 B
Overall change 1.83 kB 1.83 kB ⚠️ +4 B

Diffs

Diff for 597-HASH.js
@@ -1919,7 +1919,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
           this.isReady = !!(
             self.__NEXT_DATA__.gssp ||
             self.__NEXT_DATA__.gip ||
-            (!autoExportDynamic && !self.location.search)
+            (!autoExportDynamic && !self.location.search && !false)
           );
           this.isPreview = !!isPreview;
           this.isLocaleDomain = false;
Diff for 778-HASH.js
@@ -520,12 +520,24 @@
               // - if it is a client-side skeleton (fallback render)
 
               if (
-                router.isSsr &&
+                router.isSsr && // We don't update for 404 requests as this can modify
+                // the asPath unexpectedly e.g. adding basePath when
+                // it wasn't originally present
+                page !== "/404" &&
+                !(
+                  page === "/_error" &&
+                  hydrateProps &&
+                  hydrateProps.pageProps &&
+                  hydrateProps.pageProps.statusCode === 404
+                ) &&
                 (isFallback ||
                   (data.nextExport &&
                     ((0, _isDynamic.isDynamicRoute)(router.pathname) ||
-                      location.search)) ||
-                  (hydrateProps && hydrateProps.__N_SSG && location.search))
+                      location.search ||
+                      false)) ||
+                  (hydrateProps &&
+                    hydrateProps.__N_SSG &&
+                    (location.search || false)))
               ) {
                 // update query on mount for exported pages
                 router.replace(
Diff for index.html
@@ -7,7 +7,7 @@
     <noscript data-n-css=""></noscript>
     <link
       rel="preload"
-      href="/_next/static/chunks/webpack-efcad16b0fa0f63cacfc.js"
+      href="/_next/static/chunks/webpack-e63d49dc8157427969e3.js"
       as="script"
     />
     <link
@@ -17,12 +17,12 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/597-3d76d013a3fba822863e.js"
+      href="/_next/static/chunks/597-ce2d8ad287ead7daa2d3.js"
       as="script"
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/778-5b575716c0bcacfbf1eb.js"
+      href="/_next/static/chunks/778-9a3bad1797977da2192b.js"
       as="script"
     />
     <link
@@ -58,7 +58,7 @@
       src="/_next/static/chunks/polyfills-8683bd742a84c1edd48c.js"
     ></script>
     <script
-      src="/_next/static/chunks/webpack-efcad16b0fa0f63cacfc.js"
+      src="/_next/static/chunks/webpack-e63d49dc8157427969e3.js"
       async=""
     ></script>
     <script
@@ -66,11 +66,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/597-3d76d013a3fba822863e.js"
+      src="/_next/static/chunks/597-ce2d8ad287ead7daa2d3.js"
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/778-5b575716c0bcacfbf1eb.js"
+      src="/_next/static/chunks/778-9a3bad1797977da2192b.js"
       async=""
     ></script>
     <script
Diff for link.html
@@ -7,7 +7,7 @@
     <noscript data-n-css=""></noscript>
     <link
       rel="preload"
-      href="/_next/static/chunks/webpack-efcad16b0fa0f63cacfc.js"
+      href="/_next/static/chunks/webpack-e63d49dc8157427969e3.js"
       as="script"
     />
     <link
@@ -17,12 +17,12 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/597-3d76d013a3fba822863e.js"
+      href="/_next/static/chunks/597-ce2d8ad287ead7daa2d3.js"
       as="script"
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/778-5b575716c0bcacfbf1eb.js"
+      href="/_next/static/chunks/778-9a3bad1797977da2192b.js"
       as="script"
     />
     <link
@@ -63,7 +63,7 @@
       src="/_next/static/chunks/polyfills-8683bd742a84c1edd48c.js"
     ></script>
     <script
-      src="/_next/static/chunks/webpack-efcad16b0fa0f63cacfc.js"
+      src="/_next/static/chunks/webpack-e63d49dc8157427969e3.js"
       async=""
     ></script>
     <script
@@ -71,11 +71,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/597-3d76d013a3fba822863e.js"
+      src="/_next/static/chunks/597-ce2d8ad287ead7daa2d3.js"
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/778-5b575716c0bcacfbf1eb.js"
+      src="/_next/static/chunks/778-9a3bad1797977da2192b.js"
       async=""
     ></script>
     <script
Diff for withRouter.html
@@ -7,7 +7,7 @@
     <noscript data-n-css=""></noscript>
     <link
       rel="preload"
-      href="/_next/static/chunks/webpack-efcad16b0fa0f63cacfc.js"
+      href="/_next/static/chunks/webpack-e63d49dc8157427969e3.js"
       as="script"
     />
     <link
@@ -17,12 +17,12 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/597-3d76d013a3fba822863e.js"
+      href="/_next/static/chunks/597-ce2d8ad287ead7daa2d3.js"
       as="script"
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/778-5b575716c0bcacfbf1eb.js"
+      href="/_next/static/chunks/778-9a3bad1797977da2192b.js"
       as="script"
     />
     <link
@@ -58,7 +58,7 @@
       src="/_next/static/chunks/polyfills-8683bd742a84c1edd48c.js"
     ></script>
     <script
-      src="/_next/static/chunks/webpack-efcad16b0fa0f63cacfc.js"
+      src="/_next/static/chunks/webpack-e63d49dc8157427969e3.js"
       async=""
     ></script>
     <script
@@ -66,11 +66,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/597-3d76d013a3fba822863e.js"
+      src="/_next/static/chunks/597-ce2d8ad287ead7daa2d3.js"
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/778-5b575716c0bcacfbf1eb.js"
+      src="/_next/static/chunks/778-9a3bad1797977da2192b.js"
       async=""
     ></script>
     <script

Serverless Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
buildDuration 19s 17.9s -1.1s
buildDurationCached 6.6s 6.3s -292ms
nodeModulesSize 46.3 MB 46.3 MB ⚠️ +1.2 kB
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
597-HASH.js gzip 13.3 kB 13.3 kB
778-HASH.js gzip 7.05 kB 7.08 kB ⚠️ +38 B
framework-HASH.js gzip 39.3 kB 39.3 kB
main-HASH.js gzip 151 B 151 B
webpack-HASH.js gzip 993 B 993 B
Overall change 60.8 kB 60.8 kB ⚠️ +38 B
Legacy Client Bundles (polyfills)
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
polyfills-HASH.js gzip 31.1 kB 31.1 kB
Overall change 31.1 kB 31.1 kB
Client Pages
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
_app-HASH.js gzip 1.3 kB 1.3 kB
_error-HASH.js gzip 3.68 kB 3.68 kB
amp-HASH.js gzip 558 B 558 B
hooks-HASH.js gzip 924 B 924 B
index-HASH.js gzip 243 B 243 B
link-HASH.js gzip 1.66 kB 1.66 kB
routerDirect..HASH.js gzip 336 B 336 B
withRouter-HASH.js gzip 334 B 334 B
Overall change 9.03 kB 9.03 kB
Client Build Manifests
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
_buildManifest.js gzip 349 B 349 B
Overall change 349 B 349 B
Serverless bundles Overall increase ⚠️
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
_error.js 1.39 MB 1.39 MB
404.html 2.76 kB 2.76 kB
500.html 2.75 kB 2.75 kB
amp.amp.html 10.7 kB 10.7 kB
amp.html 1.96 kB 1.96 kB
hooks.html 2.01 kB 2.01 kB
index.js 1.39 MB 1.39 MB
link.js 1.45 MB 1.45 MB ⚠️ +10 B
routerDirect.js 1.44 MB 1.44 MB ⚠️ +10 B
withRouter.js 1.44 MB 1.44 MB ⚠️ +10 B
Overall change 7.15 MB 7.15 MB ⚠️ +30 B

Webpack 4 Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
buildDuration 12.5s 12s -437ms
buildDurationCached 5.1s 5s -115ms
nodeModulesSize 46.3 MB 46.3 MB ⚠️ +1.2 kB
Page Load Tests Overall increase ✓
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
/ failed reqs 0 0
/ total time (seconds) 2.917 2.838 -0.08
/ avg req/sec 857.17 880.92 +23.75
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.575 1.535 -0.04
/error-in-render avg req/sec 1587.22 1628.15 +40.93
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
677f882d2ed8..HASH.js gzip 13.4 kB 13.4 kB
framework.HASH.js gzip 39 kB 39 kB
main-HASH.js gzip 7.12 kB 7.16 kB ⚠️ +40 B
webpack-HASH.js gzip 751 B 751 B
Overall change 60.2 kB 60.2 kB ⚠️ +40 B
Legacy Client Bundles (polyfills)
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
polyfills-HASH.js gzip 31.3 kB 31.3 kB
Overall change 31.3 kB 31.3 kB
Client Pages
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
_app-HASH.js gzip 1.28 kB 1.28 kB
_error-HASH.js gzip 3.71 kB 3.71 kB
amp-HASH.js gzip 536 B 536 B
hooks-HASH.js gzip 888 B 888 B
index-HASH.js gzip 227 B 227 B
link-HASH.js gzip 1.64 kB 1.64 kB
routerDirect..HASH.js gzip 303 B 303 B
withRouter-HASH.js gzip 302 B 302 B
Overall change 8.89 kB 8.89 kB
Client Build Manifests
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
_buildManifest.js gzip 371 B 371 B
Overall change 371 B 371 B
Rendered Page Sizes Overall decrease ✓
vercel/next.js canary ijjk/next.js fix/auto-export-rewrite-params Change
index.html gzip 613 B 613 B
link.html gzip 620 B 618 B -2 B
withRouter.html gzip 609 B 607 B -2 B
Overall change 1.84 kB 1.84 kB -4 B

Diffs

Diff for 677f882d2ed8..c4df.HASH.js
@@ -1755,7 +1755,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
           this.isReady = !!(
             self.__NEXT_DATA__.gssp ||
             self.__NEXT_DATA__.gip ||
-            (!autoExportDynamic && !self.location.search)
+            (!autoExportDynamic && !self.location.search && !false)
           );
           this.isPreview = !!isPreview;
           this.isLocaleDomain = false;
Diff for main-HASH.js
@@ -522,12 +522,24 @@ _N_E = (window["webpackJsonp_N_E"] = window["webpackJsonp_N_E"] || []).push([
               // - if it is a client-side skeleton (fallback render)
 
               if (
-                router.isSsr &&
+                router.isSsr && // We don't update for 404 requests as this can modify
+                // the asPath unexpectedly e.g. adding basePath when
+                // it wasn't originally present
+                page !== "/404" &&
+                !(
+                  page === "/_error" &&
+                  hydrateProps &&
+                  hydrateProps.pageProps &&
+                  hydrateProps.pageProps.statusCode === 404
+                ) &&
                 (isFallback ||
                   (data.nextExport &&
                     ((0, _isDynamic.isDynamicRoute)(router.pathname) ||
-                      location.search)) ||
-                  (hydrateProps && hydrateProps.__N_SSG && location.search))
+                      location.search ||
+                      false)) ||
+                  (hydrateProps &&
+                    hydrateProps.__N_SSG &&
+                    (location.search || false)))
               ) {
                 // update query on mount for exported pages
                 router.replace(
Diff for index.html
@@ -17,12 +17,12 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.0319a78fd6b18e9c7baf.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.95fa13665e1988802dfd.js"
       as="script"
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/main-68872973a2f90e2eea94.js"
+      href="/_next/static/chunks/main-cd8309a5d2810f21d24d.js"
       as="script"
     />
     <link
@@ -61,11 +61,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.0319a78fd6b18e9c7baf.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.95fa13665e1988802dfd.js"
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/main-68872973a2f90e2eea94.js"
+      src="/_next/static/chunks/main-cd8309a5d2810f21d24d.js"
       async=""
     ></script>
     <script
Diff for link.html
@@ -17,12 +17,12 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.0319a78fd6b18e9c7baf.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.95fa13665e1988802dfd.js"
       as="script"
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/main-68872973a2f90e2eea94.js"
+      href="/_next/static/chunks/main-cd8309a5d2810f21d24d.js"
       as="script"
     />
     <link
@@ -66,11 +66,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.0319a78fd6b18e9c7baf.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.95fa13665e1988802dfd.js"
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/main-68872973a2f90e2eea94.js"
+      src="/_next/static/chunks/main-cd8309a5d2810f21d24d.js"
       async=""
     ></script>
     <script
Diff for withRouter.html
@@ -17,12 +17,12 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.0319a78fd6b18e9c7baf.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.95fa13665e1988802dfd.js"
       as="script"
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/main-68872973a2f90e2eea94.js"
+      href="/_next/static/chunks/main-cd8309a5d2810f21d24d.js"
       as="script"
     />
     <link
@@ -61,11 +61,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.0319a78fd6b18e9c7baf.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.95fa13665e1988802dfd.js"
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/main-68872973a2f90e2eea94.js"
+      src="/_next/static/chunks/main-cd8309a5d2810f21d24d.js"
       async=""
     ></script>
     <script
Commit: 5566195

@kodiakhq kodiakhq bot merged commit 6558808 into vercel:canary Apr 18, 2021
@ijjk ijjk deleted the fix/auto-export-rewrite-params branch April 18, 2021 12:02
SokratisVidros pushed a commit to SokratisVidros/next.js that referenced this pull request Apr 20, 2021
…cel#24189)

This updates the query refreshing on the client to also refresh when rewrites are used and the page is static since additional query values can be provided from rewrites that are relied on client-side. An additional test has been added in the custom-routes suite to ensure this is working correctly. 

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added

Fixes: vercel#23490
Fixes: vercel#22931
Fixes: vercel#21062
@vercel vercel locked as resolved and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants