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

Make sure to break rewrites chain when dynamic route matches #16455

Merged
merged 2 commits into from
Aug 22, 2020

Conversation

ijjk
Copy link
Member

@ijjk ijjk commented Aug 21, 2020

This makes sure to also check if a dynamic route matched after resolving a rewrite on the client to match behavior on the server. It also adds tests for this behavior to ensure it is working properly.

Fixes: #16454

@ijjk
Copy link
Member Author

ijjk commented Aug 21, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary ijjk/next.js fix/client-rewrite-resolving Change
buildDuration 12.9s 12.8s -130ms
nodeModulesSize 57.5 MB 57.5 MB ⚠️ +952 B
Page Load Tests Overall increase ✓
vercel/next.js canary ijjk/next.js fix/client-rewrite-resolving Change
/ failed reqs 0 0
/ total time (seconds) 2.425 2.392 -0.03
/ avg req/sec 1030.92 1045.3 +14.38
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.43 1.436 ⚠️ +0.01
/error-in-render avg req/sec 1747.78 1741.33 ⚠️ -6.45
Client Bundles (main, webpack, commons)
vercel/next.js canary ijjk/next.js fix/client-rewrite-resolving Change
677f882d2ed8..4e55.js gzip 10.2 kB 10.2 kB
framework.HASH.js gzip 39 kB 39 kB
main-3aeb17d..193e.js gzip 7.2 kB 7.2 kB
webpack-e067..f178.js gzip 751 B 751 B
Overall change 57.2 kB 57.2 kB
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary ijjk/next.js fix/client-rewrite-resolving Change
677f882d2ed8..dule.js gzip 6.11 kB 6.11 kB
framework.HA..dule.js gzip 39 kB 39 kB
main-e67bd4d..dule.js gzip 6.21 kB 6.21 kB
webpack-07c5..dule.js gzip 751 B 751 B
Overall change 52 kB 52 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary ijjk/next.js fix/client-rewrite-resolving Change
polyfills-4b..e242.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary ijjk/next.js fix/client-rewrite-resolving Change
_app-9a0b9e1..b37e.js gzip 1.28 kB 1.28 kB
_error-28298..e0c9.js gzip 3.44 kB 3.44 kB
hooks-89731c..c609.js gzip 887 B 887 B
index-17468f..5d83.js gzip 227 B 227 B
link-000f151..65d4.js gzip 1.29 kB 1.29 kB
routerDirect..924c.js gzip 284 B 284 B
withRouter-7..c13d.js gzip 284 B 284 B
Overall change 7.69 kB 7.69 kB
Client Pages Modern
vercel/next.js canary ijjk/next.js fix/client-rewrite-resolving Change
_app-75d3a82..dule.js gzip 625 B 625 B
_error-65c8a..dule.js gzip 2.29 kB 2.29 kB
hooks-cbf13f..dule.js gzip 387 B 387 B
index-b9a643..dule.js gzip 226 B 226 B
link-4cfda7a..dule.js gzip 1.26 kB 1.26 kB
routerDirect..dule.js gzip 284 B 284 B
withRouter-f..dule.js gzip 282 B 282 B
Overall change 5.35 kB 5.35 kB
Client Build Manifests
vercel/next.js canary ijjk/next.js fix/client-rewrite-resolving Change
_buildManifest.js gzip 322 B 322 B
_buildManife..dule.js gzip 330 B 330 B
Overall change 652 B 652 B
Rendered Page Sizes Overall decrease ✓
vercel/next.js canary ijjk/next.js fix/client-rewrite-resolving Change
index.html gzip 946 B 945 B -1 B
link.html gzip 952 B 952 B
withRouter.html gzip 937 B 937 B
Overall change 2.83 kB 2.83 kB -1 B

Diffs

Diff for 677f882d2ed8..d7bfae669.js
@@ -1098,6 +1098,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                   as,
                   options
                 ) {
+                  var _this2 = this;
+
                   var cleanedAs,
                     pages,
                     _yield$this$pageLoade,
@@ -1531,7 +1533,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                   query,
                   as
                 ) {
-                  var _this2 = this;
+                  var _this3 = this;
 
                   var shallow,
                     cachedRouteInfo,
@@ -1646,10 +1648,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             _context3.next = 21;
                             return this._getData(function() {
                               return __N_SSG
-                                ? _this2._getStaticData(dataHref)
+                                ? _this3._getStaticData(dataHref)
                                 : __N_SSP
-                                ? _this2._getServerData(dataHref)
-                                : _this2.getInitialProps(
+                                ? _this3._getServerData(dataHref)
+                                : _this3.getInitialProps(
                                     Component, // we provide AppTree later so this needs to be `any`
                                     {
                                       pathname: pathname,
@@ -1976,7 +1978,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
           {
             key: "_getData",
             value: function _getData(fn) {
-              var _this3 = this;
+              var _this4 = this;
 
               var cancelled = false;
 
@@ -1986,8 +1988,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
 
               this.clc = cancel;
               return fn().then(function(data) {
-                if (cancel === _this3.clc) {
-                  _this3.clc = null;
+                if (cancel === _this4.clc) {
+                  _this4.clc = null;
                 }
 
                 if (cancelled) {
@@ -2003,7 +2005,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
           {
             key: "_getStaticData",
             value: function _getStaticData(dataHref) {
-              var _this4 = this;
+              var _this5 = this;
 
               var _URL = new URL(dataHref, window.location.href),
                 cacheKey = _URL.href;
@@ -2013,7 +2015,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
               }
 
               return fetchNextData(dataHref, this.isSsr).then(function(data) {
-                _this4.sdc[cacheKey] = data;
+                _this5.sdc[cacheKey] = data;
                 return data;
               });
             }
Diff for index.html
@@ -24,7 +24,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.2246dbcf7266d80d2e3f.module.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.e757038339ef53dbeb92.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -117,13 +117,13 @@
       type="module"
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.5f98775e8cad7bfae669.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.65b1856febc630f20327.js"
       async=""
       crossorigin="anonymous"
       nomodule=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.2246dbcf7266d80d2e3f.module.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.e757038339ef53dbeb92.module.js"
       async=""
       crossorigin="anonymous"
       type="module"
Diff for link.html
@@ -24,7 +24,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.2246dbcf7266d80d2e3f.module.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.e757038339ef53dbeb92.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -122,13 +122,13 @@
       type="module"
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.5f98775e8cad7bfae669.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.65b1856febc630f20327.js"
       async=""
       crossorigin="anonymous"
       nomodule=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.2246dbcf7266d80d2e3f.module.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.e757038339ef53dbeb92.module.js"
       async=""
       crossorigin="anonymous"
       type="module"
Diff for withRouter.html
@@ -24,7 +24,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.2246dbcf7266d80d2e3f.module.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.e757038339ef53dbeb92.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -117,13 +117,13 @@
       type="module"
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.5f98775e8cad7bfae669.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.65b1856febc630f20327.js"
       async=""
       crossorigin="anonymous"
       nomodule=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.2246dbcf7266d80d2e3f.module.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.e757038339ef53dbeb92.module.js"
       async=""
       crossorigin="anonymous"
       type="module"

Serverless Mode
General Overall increase ⚠️
vercel/next.js canary ijjk/next.js fix/client-rewrite-resolving Change
buildDuration 14.7s 14.3s -368ms
nodeModulesSize 57.5 MB 57.5 MB ⚠️ +952 B
Client Bundles (main, webpack, commons)
vercel/next.js canary ijjk/next.js fix/client-rewrite-resolving Change
677f882d2ed8..4e55.js gzip 10.2 kB N/A N/A
framework.HASH.js gzip 39 kB 39 kB
main-3aeb17d..193e.js gzip 7.2 kB 7.2 kB
webpack-e067..f178.js gzip 751 B 751 B
677f882d2ed8..1962.js gzip N/A 10.2 kB N/A
Overall change 57.2 kB 57.2 kB
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary ijjk/next.js fix/client-rewrite-resolving Change
677f882d2ed8..dule.js gzip 6.11 kB N/A N/A
framework.HA..dule.js gzip 39 kB 39 kB
main-e67bd4d..dule.js gzip 6.21 kB 6.21 kB
webpack-07c5..dule.js gzip 751 B 751 B
677f882d2ed8..dule.js gzip N/A 6.11 kB N/A
Overall change 52 kB 52 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary ijjk/next.js fix/client-rewrite-resolving Change
polyfills-4b..e242.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary ijjk/next.js fix/client-rewrite-resolving Change
_app-9a0b9e1..b37e.js gzip 1.28 kB 1.28 kB
_error-28298..e0c9.js gzip 3.44 kB 3.44 kB
hooks-89731c..c609.js gzip 887 B 887 B
index-17468f..5d83.js gzip 227 B 227 B
link-000f151..65d4.js gzip 1.29 kB 1.29 kB
routerDirect..924c.js gzip 284 B 284 B
withRouter-7..c13d.js gzip 284 B 284 B
Overall change 7.69 kB 7.69 kB
Client Pages Modern
vercel/next.js canary ijjk/next.js fix/client-rewrite-resolving Change
_app-75d3a82..dule.js gzip 625 B 625 B
_error-65c8a..dule.js gzip 2.29 kB 2.29 kB
hooks-cbf13f..dule.js gzip 387 B 387 B
index-b9a643..dule.js gzip 226 B 226 B
link-4cfda7a..dule.js gzip 1.26 kB 1.26 kB
routerDirect..dule.js gzip 284 B 284 B
withRouter-f..dule.js gzip 282 B 282 B
Overall change 5.35 kB 5.35 kB
Client Build Manifests
vercel/next.js canary ijjk/next.js fix/client-rewrite-resolving Change
_buildManifest.js gzip 322 B 322 B
_buildManife..dule.js gzip 330 B 330 B
Overall change 652 B 652 B
Serverless bundles
vercel/next.js canary ijjk/next.js fix/client-rewrite-resolving Change
_error.js 1.03 MB 1.03 MB
404.html 4.18 kB 4.18 kB
hooks.html 3.82 kB 3.82 kB
index.js 1.03 MB 1.03 MB
link.js 1.07 MB 1.07 MB
routerDirect.js 1.07 MB 1.07 MB
withRouter.js 1.07 MB 1.07 MB
Overall change 5.28 MB 5.28 MB
Commit: 2cc6abf

@kodiakhq kodiakhq bot merged commit 8a1c993 into vercel:canary Aug 22, 2020
@Timer Timer deleted the fix/client-rewrite-resolving branch August 22, 2020 05:15
@vercel vercel locked as resolved and limited conversation to collaborators Jan 30, 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.

Rewrites resolving on the client should break after matching dynamic route
2 participants