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

Fix base path handling with URL queries in dev server #13560

Merged
merged 9 commits into from
Jun 5, 2020

Conversation

TyMick
Copy link
Contributor

@TyMick TyMick commented May 29, 2020

So I can't entirely explain why, but I believe this fixes #13132. 🙈 I basically ended up looking around at other _next URLs (are those asset URLs?) around the project and seeing that they tended to use delBasePath() to remove the base path from the current page's path whenever it was used.

When testing locally with the repo submitted with the issue, I no longer experience the constant page-reloading in dev mode when adding a query string to the URL.

@daveskybet
Copy link

Just tested this locally as was working on a fix myself for a similar issue.

This fixes the issue I was having with catch all routes in dev with basePath reloading unexpectedly when navigating between two pages that resolve to the same catch all route, which would fall foul of the logic in handlePing() in on-demand-entry-handler.ts as the page it receives still contained the basePath.

Timer
Timer previously requested changes Jun 2, 2020
Copy link
Member

@Timer Timer left a comment

Choose a reason for hiding this comment

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

Could you please add a test for this? If you can't get around to it, I'll add it within the next week.

@TyMick
Copy link
Contributor Author

TyMick commented Jun 5, 2020

Added a test which opens /docs/hello?query=true, waits 6 seconds (since the timeout of the EventSource in setupPing() is 5 seconds), and checks if the the window refreshed. Is setting a timeout within a promise a good method of waiting in these tests?

it('should allow URL query strings without refresh', async () => {
  const browser = await webdriver(context.appPort, '/docs/hello?query=true')
  try {
    await browser.eval('window.itdidnotrefresh = "hello"')
    await new Promise((resolve, reject) => {
      // Timeout of EventSource created in setupPing()
      // (on-demand-entries-utils.js) is 5000 ms (see #13132, #13560)
      setTimeout(resolve, 6000)
    })
    expect(await browser.eval('window.itdidnotrefresh')).toBe('hello')
  } finally {
    await browser.close()
  }
})

This new test succeeds with the changes in this PR and fails in the dev environment without them.

Any other aspects we ought to test that I missed?

@TyMick TyMick changed the title Fix base path handling in dev server Fix base path handling with URL queries in dev server Jun 5, 2020
@ijjk
Copy link
Member

ijjk commented Jun 5, 2020

Stats from current PR

Default Server Mode (Decrease detected ✓)
General Overall increase ⚠️
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
buildDuration 14.1s 13.8s -229ms
nodeModulesSize 66 MB 66 MB ⚠️ +193 B
Page Load Tests Overall decrease ⚠️
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
/ failed reqs 0 0
/ total time (seconds) 2.409 2.481 ⚠️ +0.07
/ avg req/sec 1037.87 1007.76 -30.11
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.538 1.595 ⚠️ +0.06
/error-in-render avg req/sec 1625.37 1567.14 -58.23
Client Bundles (main, webpack, commons)
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
main-HASH.js gzip 6.61 kB 6.61 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..6c2a.js gzip 10.5 kB 10.5 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 57 kB 57 kB
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
main-HASH.module.js gzip 5.69 kB 5.69 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.93 kB 6.93 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 52.5 kB 52.5 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_app.js gzip 1.26 kB 1.26 kB
_error.js gzip 3.25 kB 3.25 kB
hooks.js gzip 881 B 881 B
index.js gzip 222 B 222 B
link.js gzip 2.05 kB 2.05 kB
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 8.21 kB 8.21 kB
Client Pages Modern
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_app.module.js gzip 604 B 604 B
_error.module.js gzip 2.04 kB 2.04 kB
hooks.module.js gzip 383 B 383 B
index.module.js gzip 223 B 223 B
link.module.js gzip 1.51 kB 1.51 kB
routerDirect..dule.js gzip 281 B 281 B
withRouter.m..dule.js gzip 278 B 278 B
Overall change 5.32 kB 5.32 kB
Client Build Manifests
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Rendered Page Sizes
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
index.html gzip 925 B 925 B
link.html gzip 935 B 935 B
withRouter.html gzip 923 B 923 B
Overall change 2.78 kB 2.78 kB

Serverless Mode
General Overall increase ⚠️
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
buildDuration 15.2s 15.3s ⚠️ +126ms
nodeModulesSize 66 MB 66 MB ⚠️ +193 B
Client Bundles (main, webpack, commons)
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
main-HASH.js gzip 6.61 kB 6.61 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..6c2a.js gzip 10.5 kB 10.5 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 57 kB 57 kB
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
main-HASH.module.js gzip 5.69 kB 5.69 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.93 kB 6.93 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 52.5 kB 52.5 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_app.js gzip 1.26 kB 1.26 kB
_error.js gzip 3.25 kB 3.25 kB
hooks.js gzip 881 B 881 B
index.js gzip 222 B 222 B
link.js gzip 2.05 kB 2.05 kB
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 8.21 kB 8.21 kB
Client Pages Modern
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_app.module.js gzip 604 B 604 B
_error.module.js gzip 2.04 kB 2.04 kB
hooks.module.js gzip 383 B 383 B
index.module.js gzip 223 B 223 B
link.module.js gzip 1.51 kB 1.51 kB
routerDirect..dule.js gzip 281 B 281 B
withRouter.m..dule.js gzip 278 B 278 B
Overall change 5.32 kB 5.32 kB
Client Build Manifests
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Serverless bundles
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_error.js 878 kB 878 kB
404.html 4.18 kB 4.18 kB
hooks.html 3.81 kB 3.81 kB
index.js 878 kB 878 kB
link.js 916 kB 916 kB
routerDirect.js 909 kB 909 kB
withRouter.js 909 kB 909 kB
Overall change 4.5 MB 4.5 MB

@ijjk ijjk added the type: next label Jun 5, 2020
@Timer Timer assigned ijjk and unassigned Timer Jun 5, 2020
@Timer Timer dismissed their stale review June 5, 2020 14:39

LGTM, waiting on review from @ijjk to confirm.

@Timer Timer added this to the 9.4.5 milestone Jun 5, 2020
@ijjk
Copy link
Member

ijjk commented Jun 5, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
buildDuration 13.2s 13.3s ⚠️ +90ms
nodeModulesSize 66 MB 66 MB ⚠️ +193 B
Page Load Tests Overall increase ✓
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
/ failed reqs 0 0
/ total time (seconds) 2.416 2.384 -0.03
/ avg req/sec 1034.85 1048.77 ⚠️ +13.92
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.56 1.445 -0.11
/error-in-render avg req/sec 1602.11 1729.94 ⚠️ +127.83
Client Bundles (main, webpack, commons)
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
main-HASH.js gzip 6.61 kB 6.61 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..6c2a.js gzip 10.5 kB 10.5 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 57 kB 57 kB
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
main-HASH.module.js gzip 5.69 kB 5.69 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.93 kB 6.93 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 52.5 kB 52.5 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_app.js gzip 1.26 kB 1.26 kB
_error.js gzip 3.25 kB 3.25 kB
hooks.js gzip 881 B 881 B
index.js gzip 222 B 222 B
link.js gzip 2.05 kB 2.05 kB
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 8.21 kB 8.21 kB
Client Pages Modern
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_app.module.js gzip 604 B 604 B
_error.module.js gzip 2.04 kB 2.04 kB
hooks.module.js gzip 383 B 383 B
index.module.js gzip 223 B 223 B
link.module.js gzip 1.51 kB 1.51 kB
routerDirect..dule.js gzip 281 B 281 B
withRouter.m..dule.js gzip 278 B 278 B
Overall change 5.32 kB 5.32 kB
Client Build Manifests
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Rendered Page Sizes
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
index.html gzip 925 B 925 B
link.html gzip 935 B 935 B
withRouter.html gzip 923 B 923 B
Overall change 2.78 kB 2.78 kB

Serverless Mode
General Overall increase ⚠️
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
buildDuration 14.8s 14.5s -303ms
nodeModulesSize 66 MB 66 MB ⚠️ +193 B
Client Bundles (main, webpack, commons)
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
main-HASH.js gzip 6.61 kB 6.61 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..6c2a.js gzip 10.5 kB 10.5 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 57 kB 57 kB
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
main-HASH.module.js gzip 5.69 kB 5.69 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.93 kB 6.93 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 52.5 kB 52.5 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_app.js gzip 1.26 kB 1.26 kB
_error.js gzip 3.25 kB 3.25 kB
hooks.js gzip 881 B 881 B
index.js gzip 222 B 222 B
link.js gzip 2.05 kB 2.05 kB
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 8.21 kB 8.21 kB
Client Pages Modern
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_app.module.js gzip 604 B 604 B
_error.module.js gzip 2.04 kB 2.04 kB
hooks.module.js gzip 383 B 383 B
index.module.js gzip 223 B 223 B
link.module.js gzip 1.51 kB 1.51 kB
routerDirect..dule.js gzip 281 B 281 B
withRouter.m..dule.js gzip 278 B 278 B
Overall change 5.32 kB 5.32 kB
Client Build Manifests
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Serverless bundles
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_error.js 878 kB 878 kB
404.html 4.18 kB 4.18 kB
hooks.html 3.81 kB 3.81 kB
index.js 878 kB 878 kB
link.js 916 kB 916 kB
routerDirect.js 909 kB 909 kB
withRouter.js 909 kB 909 kB
Overall change 4.5 MB 4.5 MB

Copy link
Member

@Timer Timer left a comment

Choose a reason for hiding this comment

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

Re-blocking, after discussion with @ijjk this is probably due to a bug with Router.pathname having the base path.

@Timer Timer self-assigned this Jun 5, 2020
@ijjk
Copy link
Member

ijjk commented Jun 5, 2020

Stats from current PR

Default Server Mode (Decrease detected ✓)
General Overall increase ⚠️
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
buildDuration 12.8s 13.1s ⚠️ +289ms
nodeModulesSize 66 MB 66 MB ⚠️ +236 B
Page Load Tests Overall decrease ⚠️
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
/ failed reqs 0 0
/ total time (seconds) 2.336 2.268 -0.07
/ avg req/sec 1070.33 1102.24 ⚠️ +31.91
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.41 1.465 ⚠️ +0.06
/error-in-render avg req/sec 1773.27 1706.32 -66.95
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
main-HASH.js gzip 6.61 kB 6.61 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..6c2a.js gzip 10.5 kB 10.5 kB ⚠️ +1 B
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 57 kB 57 kB ⚠️ +1 B
Client Bundles (main, webpack, commons) Modern Overall decrease ✓
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
main-HASH.module.js gzip 5.69 kB 5.69 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.93 kB 6.92 kB -1 B
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 52.5 kB 52.5 kB -1 B
Legacy Client Bundles (polyfills)
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_app.js gzip 1.26 kB 1.26 kB
_error.js gzip 3.25 kB 3.25 kB
hooks.js gzip 881 B 881 B
index.js gzip 222 B 222 B
link.js gzip 2.05 kB 2.05 kB
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 8.21 kB 8.21 kB
Client Pages Modern
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_app.module.js gzip 604 B 604 B
_error.module.js gzip 2.04 kB 2.04 kB
hooks.module.js gzip 383 B 383 B
index.module.js gzip 223 B 223 B
link.module.js gzip 1.51 kB 1.51 kB
routerDirect..dule.js gzip 281 B 281 B
withRouter.m..dule.js gzip 278 B 278 B
Overall change 5.32 kB 5.32 kB
Client Build Manifests
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Rendered Page Sizes Overall increase ⚠️
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
index.html gzip 925 B 927 B ⚠️ +2 B
link.html gzip 935 B 936 B ⚠️ +1 B
withRouter.html gzip 923 B 924 B ⚠️ +1 B
Overall change 2.78 kB 2.79 kB ⚠️ +4 B

Diffs

Diff for de003c3a9d30..8a09594e6.js
@@ -1090,7 +1090,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                   var as =
                     typeof _as === "object"
                       ? (0, _utils.formatWithValidation)(_as)
-                      : _as;
+                      : _as; // parse url parts without basePath since pathname should map 1-1 with
+                  // pages dir
+
+                  var _ref3 = (0, _url2.parse)(delBasePath(url), true),
+                    pathname = _ref3.pathname,
+                    query = _ref3.query,
+                    protocol = _ref3.protocol;
+
                   url = addBasePath(url);
                   as = addBasePath(as); // Add the ending slash to the paths. So, we can serve the
                   // "<page>/index.html" directly for the SSR page.
@@ -1117,11 +1124,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     return resolve(true);
                   }
 
-                  var _ref3 = (0, _url2.parse)(url, true),
-                    pathname = _ref3.pathname,
-                    query = _ref3.query,
-                    protocol = _ref3.protocol;
-
                   if (!pathname || protocol) {
                     if (false) {
                     }
Diff for de003c3a9d30..34.module.js
@@ -941,7 +941,13 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
             var as =
               typeof _as === "object"
                 ? (0, _utils.formatWithValidation)(_as)
-                : _as;
+                : _as; // parse url parts without basePath since pathname should map 1-1 with
+            // pages dir
+
+            var { pathname, query, protocol } = (0, _url2.parse)(
+              delBasePath(url),
+              true
+            );
             url = addBasePath(url);
             as = addBasePath(as); // Add the ending slash to the paths. So, we can serve the
             // "<page>/index.html" directly for the SSR page.
@@ -965,8 +971,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
               return resolve(true);
             }
 
-            var { pathname, query, protocol } = (0, _url2.parse)(url, true);
-
             if (!pathname || protocol) {
               if (false) {
               }
Diff for index.html
@@ -30,7 +30,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2a9df3ecdcd8c7823f34.module.js"
+      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.9a53c0354b7704786358.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -133,13 +133,13 @@
       type="module"
     ></script>
     <script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.133d5a9780b8a09594e6.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.0d9426f7161afec2141f.js"
       async=""
       crossorigin="anonymous"
       nomodule=""
     ></script>
     <script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2a9df3ecdcd8c7823f34.module.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.9a53c0354b7704786358.module.js"
       async=""
       crossorigin="anonymous"
       type="module"
Diff for link.html
@@ -30,7 +30,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2a9df3ecdcd8c7823f34.module.js"
+      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.9a53c0354b7704786358.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -138,13 +138,13 @@
       type="module"
     ></script>
     <script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.133d5a9780b8a09594e6.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.0d9426f7161afec2141f.js"
       async=""
       crossorigin="anonymous"
       nomodule=""
     ></script>
     <script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2a9df3ecdcd8c7823f34.module.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.9a53c0354b7704786358.module.js"
       async=""
       crossorigin="anonymous"
       type="module"
Diff for withRouter.html
@@ -30,7 +30,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2a9df3ecdcd8c7823f34.module.js"
+      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.9a53c0354b7704786358.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -133,13 +133,13 @@
       type="module"
     ></script>
     <script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.133d5a9780b8a09594e6.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.0d9426f7161afec2141f.js"
       async=""
       crossorigin="anonymous"
       nomodule=""
     ></script>
     <script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2a9df3ecdcd8c7823f34.module.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.9a53c0354b7704786358.module.js"
       async=""
       crossorigin="anonymous"
       type="module"

Serverless Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
buildDuration 13.8s 13.7s -146ms
nodeModulesSize 66 MB 66 MB ⚠️ +236 B
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
main-HASH.js gzip 6.61 kB 6.61 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..6c2a.js gzip 10.5 kB N/A N/A
framework.HASH.js gzip 39.1 kB 39.1 kB
de003c3a9d30..9545.js gzip N/A 10.5 kB N/A
Overall change 57 kB 57 kB ⚠️ +1 B
Client Bundles (main, webpack, commons) Modern Overall decrease ✓
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
main-HASH.module.js gzip 5.69 kB 5.69 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.93 kB N/A N/A
framework.HA..dule.js gzip 39.1 kB 39.1 kB
de003c3a9d30..dule.js gzip N/A 6.92 kB N/A
Overall change 52.5 kB 52.5 kB -1 B
Legacy Client Bundles (polyfills)
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_app.js gzip 1.26 kB 1.26 kB
_error.js gzip 3.25 kB 3.25 kB
hooks.js gzip 881 B 881 B
index.js gzip 222 B 222 B
link.js gzip 2.05 kB 2.05 kB
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 8.21 kB 8.21 kB
Client Pages Modern
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_app.module.js gzip 604 B 604 B
_error.module.js gzip 2.04 kB 2.04 kB
hooks.module.js gzip 383 B 383 B
index.module.js gzip 223 B 223 B
link.module.js gzip 1.51 kB 1.51 kB
routerDirect..dule.js gzip 281 B 281 B
withRouter.m..dule.js gzip 278 B 278 B
Overall change 5.32 kB 5.32 kB
Client Build Manifests
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Serverless bundles Overall increase ⚠️
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_error.js 878 kB 878 kB
404.html 4.18 kB 4.18 kB
hooks.html 3.81 kB 3.81 kB
index.js 878 kB 878 kB
link.js 916 kB 916 kB ⚠️ +103 B
routerDirect.js 909 kB 909 kB ⚠️ +103 B
withRouter.js 909 kB 909 kB ⚠️ +103 B
Overall change 4.5 MB 4.5 MB ⚠️ +309 B

Copy link
Member

@ijjk ijjk left a comment

Choose a reason for hiding this comment

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

Hi, it looks like the cause was from the pathname being prefixed when it shouldn't since it should map 1-1 with the pages dir. I updated this PR to address it in this way and the test looks good 👍

@ijjk ijjk requested a review from Timer June 5, 2020 15:11
@Timer Timer added the kind: bug label Jun 5, 2020
@ijjk
Copy link
Member

ijjk commented Jun 5, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
buildDuration 10.7s 10.6s -7ms
nodeModulesSize 66 MB 66 MB ⚠️ +236 B
Page Load Tests Overall increase ✓
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
/ failed reqs 0 0
/ total time (seconds) 1.933 1.804 -0.13
/ avg req/sec 1293.02 1385.84 ⚠️ +92.82
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.015 1.027 ⚠️ +0.01
/error-in-render avg req/sec 2462.8 2434.15 -28.65
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
main-HASH.js gzip 6.61 kB 6.61 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..6c2a.js gzip 10.5 kB 10.5 kB ⚠️ +1 B
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 57 kB 57 kB ⚠️ +1 B
Client Bundles (main, webpack, commons) Modern Overall decrease ✓
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
main-HASH.module.js gzip 5.69 kB 5.69 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.93 kB 6.92 kB -1 B
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 52.5 kB 52.5 kB -1 B
Legacy Client Bundles (polyfills)
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_app.js gzip 1.26 kB 1.26 kB
_error.js gzip 3.25 kB 3.25 kB
hooks.js gzip 881 B 881 B
index.js gzip 222 B 222 B
link.js gzip 2.05 kB 2.05 kB
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 8.21 kB 8.21 kB
Client Pages Modern
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_app.module.js gzip 604 B 604 B
_error.module.js gzip 2.04 kB 2.04 kB
hooks.module.js gzip 383 B 383 B
index.module.js gzip 223 B 223 B
link.module.js gzip 1.51 kB 1.51 kB
routerDirect..dule.js gzip 281 B 281 B
withRouter.m..dule.js gzip 278 B 278 B
Overall change 5.32 kB 5.32 kB
Client Build Manifests
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Rendered Page Sizes Overall increase ⚠️
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
index.html gzip 925 B 927 B ⚠️ +2 B
link.html gzip 935 B 936 B ⚠️ +1 B
withRouter.html gzip 923 B 924 B ⚠️ +1 B
Overall change 2.78 kB 2.79 kB ⚠️ +4 B

Diffs

Diff for de003c3a9d30..8a09594e6.js
@@ -1090,7 +1090,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                   var as =
                     typeof _as === "object"
                       ? (0, _utils.formatWithValidation)(_as)
-                      : _as;
+                      : _as; // parse url parts without basePath since pathname should map 1-1 with
+                  // pages dir
+
+                  var _ref3 = (0, _url2.parse)(delBasePath(url), true),
+                    pathname = _ref3.pathname,
+                    query = _ref3.query,
+                    protocol = _ref3.protocol;
+
                   url = addBasePath(url);
                   as = addBasePath(as); // Add the ending slash to the paths. So, we can serve the
                   // "<page>/index.html" directly for the SSR page.
@@ -1117,11 +1124,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     return resolve(true);
                   }
 
-                  var _ref3 = (0, _url2.parse)(url, true),
-                    pathname = _ref3.pathname,
-                    query = _ref3.query,
-                    protocol = _ref3.protocol;
-
                   if (!pathname || protocol) {
                     if (false) {
                     }
Diff for de003c3a9d30..34.module.js
@@ -941,7 +941,13 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
             var as =
               typeof _as === "object"
                 ? (0, _utils.formatWithValidation)(_as)
-                : _as;
+                : _as; // parse url parts without basePath since pathname should map 1-1 with
+            // pages dir
+
+            var { pathname, query, protocol } = (0, _url2.parse)(
+              delBasePath(url),
+              true
+            );
             url = addBasePath(url);
             as = addBasePath(as); // Add the ending slash to the paths. So, we can serve the
             // "<page>/index.html" directly for the SSR page.
@@ -965,8 +971,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
               return resolve(true);
             }
 
-            var { pathname, query, protocol } = (0, _url2.parse)(url, true);
-
             if (!pathname || protocol) {
               if (false) {
               }
Diff for index.html
@@ -30,7 +30,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2a9df3ecdcd8c7823f34.module.js"
+      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.9a53c0354b7704786358.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -133,13 +133,13 @@
       type="module"
     ></script>
     <script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.133d5a9780b8a09594e6.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.0d9426f7161afec2141f.js"
       async=""
       crossorigin="anonymous"
       nomodule=""
     ></script>
     <script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2a9df3ecdcd8c7823f34.module.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.9a53c0354b7704786358.module.js"
       async=""
       crossorigin="anonymous"
       type="module"
Diff for link.html
@@ -30,7 +30,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2a9df3ecdcd8c7823f34.module.js"
+      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.9a53c0354b7704786358.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -138,13 +138,13 @@
       type="module"
     ></script>
     <script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.133d5a9780b8a09594e6.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.0d9426f7161afec2141f.js"
       async=""
       crossorigin="anonymous"
       nomodule=""
     ></script>
     <script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2a9df3ecdcd8c7823f34.module.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.9a53c0354b7704786358.module.js"
       async=""
       crossorigin="anonymous"
       type="module"
Diff for withRouter.html
@@ -30,7 +30,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2a9df3ecdcd8c7823f34.module.js"
+      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.9a53c0354b7704786358.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -133,13 +133,13 @@
       type="module"
     ></script>
     <script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.133d5a9780b8a09594e6.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.0d9426f7161afec2141f.js"
       async=""
       crossorigin="anonymous"
       nomodule=""
     ></script>
     <script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2a9df3ecdcd8c7823f34.module.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.9a53c0354b7704786358.module.js"
       async=""
       crossorigin="anonymous"
       type="module"

Serverless Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
buildDuration 11.9s 11.9s -49ms
nodeModulesSize 66 MB 66 MB ⚠️ +236 B
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
main-HASH.js gzip 6.61 kB 6.61 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..6c2a.js gzip 10.5 kB N/A N/A
framework.HASH.js gzip 39.1 kB 39.1 kB
de003c3a9d30..9545.js gzip N/A 10.5 kB N/A
Overall change 57 kB 57 kB ⚠️ +1 B
Client Bundles (main, webpack, commons) Modern Overall decrease ✓
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
main-HASH.module.js gzip 5.69 kB 5.69 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.93 kB N/A N/A
framework.HA..dule.js gzip 39.1 kB 39.1 kB
de003c3a9d30..dule.js gzip N/A 6.92 kB N/A
Overall change 52.5 kB 52.5 kB -1 B
Legacy Client Bundles (polyfills)
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_app.js gzip 1.26 kB 1.26 kB
_error.js gzip 3.25 kB 3.25 kB
hooks.js gzip 881 B 881 B
index.js gzip 222 B 222 B
link.js gzip 2.05 kB 2.05 kB
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 8.21 kB 8.21 kB
Client Pages Modern
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_app.module.js gzip 604 B 604 B
_error.module.js gzip 2.04 kB 2.04 kB
hooks.module.js gzip 383 B 383 B
index.module.js gzip 223 B 223 B
link.module.js gzip 1.51 kB 1.51 kB
routerDirect..dule.js gzip 281 B 281 B
withRouter.m..dule.js gzip 278 B 278 B
Overall change 5.32 kB 5.32 kB
Client Build Manifests
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Serverless bundles Overall increase ⚠️
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_error.js 878 kB 878 kB
404.html 4.18 kB 4.18 kB
hooks.html 3.81 kB 3.81 kB
index.js 878 kB 878 kB
link.js 916 kB 916 kB ⚠️ +103 B
routerDirect.js 909 kB 909 kB ⚠️ +103 B
withRouter.js 909 kB 909 kB ⚠️ +103 B
Overall change 4.5 MB 4.5 MB ⚠️ +309 B

@ijjk
Copy link
Member

ijjk commented Jun 5, 2020

Stats from current PR

Default Server Mode (Decrease detected ✓)
General Overall increase ⚠️
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
buildDuration 13.1s 13.2s ⚠️ +184ms
nodeModulesSize 66 MB 66 MB ⚠️ +236 B
Page Load Tests Overall decrease ⚠️
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
/ failed reqs 0 0
/ total time (seconds) 2.301 2.336 ⚠️ +0.03
/ avg req/sec 1086.41 1070.14 -16.27
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.517 1.518 0
/error-in-render avg req/sec 1648.5 1647.33 -1.17
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
main-HASH.js gzip 6.61 kB 6.61 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..6c2a.js gzip 10.5 kB 10.5 kB ⚠️ +1 B
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 57 kB 57 kB ⚠️ +1 B
Client Bundles (main, webpack, commons) Modern Overall decrease ✓
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
main-HASH.module.js gzip 5.69 kB 5.69 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.93 kB 6.92 kB -1 B
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 52.5 kB 52.5 kB -1 B
Legacy Client Bundles (polyfills)
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_app.js gzip 1.26 kB 1.26 kB
_error.js gzip 3.25 kB 3.25 kB
hooks.js gzip 881 B 881 B
index.js gzip 222 B 222 B
link.js gzip 2.05 kB 2.05 kB
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 8.21 kB 8.21 kB
Client Pages Modern
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_app.module.js gzip 604 B 604 B
_error.module.js gzip 2.04 kB 2.04 kB
hooks.module.js gzip 383 B 383 B
index.module.js gzip 223 B 223 B
link.module.js gzip 1.51 kB 1.51 kB
routerDirect..dule.js gzip 281 B 281 B
withRouter.m..dule.js gzip 278 B 278 B
Overall change 5.32 kB 5.32 kB
Client Build Manifests
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Rendered Page Sizes Overall increase ⚠️
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
index.html gzip 925 B 927 B ⚠️ +2 B
link.html gzip 935 B 936 B ⚠️ +1 B
withRouter.html gzip 923 B 924 B ⚠️ +1 B
Overall change 2.78 kB 2.79 kB ⚠️ +4 B

Diffs

Diff for de003c3a9d30..8a09594e6.js
@@ -1090,7 +1090,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                   var as =
                     typeof _as === "object"
                       ? (0, _utils.formatWithValidation)(_as)
-                      : _as;
+                      : _as; // parse url parts without basePath since pathname should map 1-1 with
+                  // pages dir
+
+                  var _ref3 = (0, _url2.parse)(delBasePath(url), true),
+                    pathname = _ref3.pathname,
+                    query = _ref3.query,
+                    protocol = _ref3.protocol;
+
                   url = addBasePath(url);
                   as = addBasePath(as); // Add the ending slash to the paths. So, we can serve the
                   // "<page>/index.html" directly for the SSR page.
@@ -1117,11 +1124,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     return resolve(true);
                   }
 
-                  var _ref3 = (0, _url2.parse)(url, true),
-                    pathname = _ref3.pathname,
-                    query = _ref3.query,
-                    protocol = _ref3.protocol;
-
                   if (!pathname || protocol) {
                     if (false) {
                     }
Diff for de003c3a9d30..34.module.js
@@ -941,7 +941,13 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
             var as =
               typeof _as === "object"
                 ? (0, _utils.formatWithValidation)(_as)
-                : _as;
+                : _as; // parse url parts without basePath since pathname should map 1-1 with
+            // pages dir
+
+            var { pathname, query, protocol } = (0, _url2.parse)(
+              delBasePath(url),
+              true
+            );
             url = addBasePath(url);
             as = addBasePath(as); // Add the ending slash to the paths. So, we can serve the
             // "<page>/index.html" directly for the SSR page.
@@ -965,8 +971,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
               return resolve(true);
             }
 
-            var { pathname, query, protocol } = (0, _url2.parse)(url, true);
-
             if (!pathname || protocol) {
               if (false) {
               }
Diff for index.html
@@ -30,7 +30,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2a9df3ecdcd8c7823f34.module.js"
+      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.9a53c0354b7704786358.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -133,13 +133,13 @@
       type="module"
     ></script>
     <script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.133d5a9780b8a09594e6.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.0d9426f7161afec2141f.js"
       async=""
       crossorigin="anonymous"
       nomodule=""
     ></script>
     <script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2a9df3ecdcd8c7823f34.module.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.9a53c0354b7704786358.module.js"
       async=""
       crossorigin="anonymous"
       type="module"
Diff for link.html
@@ -30,7 +30,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2a9df3ecdcd8c7823f34.module.js"
+      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.9a53c0354b7704786358.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -138,13 +138,13 @@
       type="module"
     ></script>
     <script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.133d5a9780b8a09594e6.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.0d9426f7161afec2141f.js"
       async=""
       crossorigin="anonymous"
       nomodule=""
     ></script>
     <script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2a9df3ecdcd8c7823f34.module.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.9a53c0354b7704786358.module.js"
       async=""
       crossorigin="anonymous"
       type="module"
Diff for withRouter.html
@@ -30,7 +30,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2a9df3ecdcd8c7823f34.module.js"
+      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.9a53c0354b7704786358.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -133,13 +133,13 @@
       type="module"
     ></script>
     <script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.133d5a9780b8a09594e6.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.0d9426f7161afec2141f.js"
       async=""
       crossorigin="anonymous"
       nomodule=""
     ></script>
     <script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2a9df3ecdcd8c7823f34.module.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.9a53c0354b7704786358.module.js"
       async=""
       crossorigin="anonymous"
       type="module"

Serverless Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
buildDuration 14s 21.2s ⚠️ +7.2s
nodeModulesSize 66 MB 66 MB ⚠️ +236 B
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
main-HASH.js gzip 6.61 kB 6.61 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..6c2a.js gzip 10.5 kB N/A N/A
framework.HASH.js gzip 39.1 kB 39.1 kB
de003c3a9d30..9545.js gzip N/A 10.5 kB N/A
Overall change 57 kB 57 kB ⚠️ +1 B
Client Bundles (main, webpack, commons) Modern Overall decrease ✓
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
main-HASH.module.js gzip 5.69 kB 5.69 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.93 kB N/A N/A
framework.HA..dule.js gzip 39.1 kB 39.1 kB
de003c3a9d30..dule.js gzip N/A 6.92 kB N/A
Overall change 52.5 kB 52.5 kB -1 B
Legacy Client Bundles (polyfills)
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_app.js gzip 1.26 kB 1.26 kB
_error.js gzip 3.25 kB 3.25 kB
hooks.js gzip 881 B 881 B
index.js gzip 222 B 222 B
link.js gzip 2.05 kB 2.05 kB
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 8.21 kB 8.21 kB
Client Pages Modern
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_app.module.js gzip 604 B 604 B
_error.module.js gzip 2.04 kB 2.04 kB
hooks.module.js gzip 383 B 383 B
index.module.js gzip 223 B 223 B
link.module.js gzip 1.51 kB 1.51 kB
routerDirect..dule.js gzip 281 B 281 B
withRouter.m..dule.js gzip 278 B 278 B
Overall change 5.32 kB 5.32 kB
Client Build Manifests
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Serverless bundles Overall increase ⚠️
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_error.js 878 kB 878 kB
404.html 4.18 kB 4.18 kB
hooks.html 3.81 kB 3.81 kB
index.js 878 kB 878 kB
link.js 916 kB 916 kB ⚠️ +103 B
routerDirect.js 909 kB 909 kB ⚠️ +103 B
withRouter.js 909 kB 909 kB ⚠️ +103 B
Overall change 4.5 MB 4.5 MB ⚠️ +309 B

@ijjk
Copy link
Member

ijjk commented Jun 5, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
buildDuration 11.8s 11.7s -82ms
nodeModulesSize 66 MB 66 MB ⚠️ +236 B
Page Load Tests Overall increase ✓
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
/ failed reqs 0 0
/ total time (seconds) 2.074 1.976 -0.1
/ avg req/sec 1205.34 1265.13 ⚠️ +59.79
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.145 1.139 -0.01
/error-in-render avg req/sec 2183.81 2194.49 ⚠️ +10.68
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
main-HASH.js gzip 6.61 kB 6.61 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..6c2a.js gzip 10.5 kB 10.5 kB ⚠️ +1 B
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 57 kB 57 kB ⚠️ +1 B
Client Bundles (main, webpack, commons) Modern Overall decrease ✓
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
main-HASH.module.js gzip 5.69 kB 5.69 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.93 kB 6.92 kB -1 B
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 52.5 kB 52.5 kB -1 B
Legacy Client Bundles (polyfills)
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_app.js gzip 1.26 kB 1.26 kB
_error.js gzip 3.25 kB 3.25 kB
hooks.js gzip 881 B 881 B
index.js gzip 222 B 222 B
link.js gzip 2.05 kB 2.05 kB
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 8.21 kB 8.21 kB
Client Pages Modern
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_app.module.js gzip 604 B 604 B
_error.module.js gzip 2.04 kB 2.04 kB
hooks.module.js gzip 383 B 383 B
index.module.js gzip 223 B 223 B
link.module.js gzip 1.51 kB 1.51 kB
routerDirect..dule.js gzip 281 B 281 B
withRouter.m..dule.js gzip 278 B 278 B
Overall change 5.32 kB 5.32 kB
Client Build Manifests
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Rendered Page Sizes Overall increase ⚠️
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
index.html gzip 925 B 927 B ⚠️ +2 B
link.html gzip 935 B 936 B ⚠️ +1 B
withRouter.html gzip 923 B 924 B ⚠️ +1 B
Overall change 2.78 kB 2.79 kB ⚠️ +4 B

Diffs

Diff for de003c3a9d30..8a09594e6.js
@@ -1090,7 +1090,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                   var as =
                     typeof _as === "object"
                       ? (0, _utils.formatWithValidation)(_as)
-                      : _as;
+                      : _as; // parse url parts without basePath since pathname should map 1-1 with
+                  // pages dir
+
+                  var _ref3 = (0, _url2.parse)(delBasePath(url), true),
+                    pathname = _ref3.pathname,
+                    query = _ref3.query,
+                    protocol = _ref3.protocol;
+
                   url = addBasePath(url);
                   as = addBasePath(as); // Add the ending slash to the paths. So, we can serve the
                   // "<page>/index.html" directly for the SSR page.
@@ -1117,11 +1124,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     return resolve(true);
                   }
 
-                  var _ref3 = (0, _url2.parse)(url, true),
-                    pathname = _ref3.pathname,
-                    query = _ref3.query,
-                    protocol = _ref3.protocol;
-
                   if (!pathname || protocol) {
                     if (false) {
                     }
Diff for de003c3a9d30..34.module.js
@@ -941,7 +941,13 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
             var as =
               typeof _as === "object"
                 ? (0, _utils.formatWithValidation)(_as)
-                : _as;
+                : _as; // parse url parts without basePath since pathname should map 1-1 with
+            // pages dir
+
+            var { pathname, query, protocol } = (0, _url2.parse)(
+              delBasePath(url),
+              true
+            );
             url = addBasePath(url);
             as = addBasePath(as); // Add the ending slash to the paths. So, we can serve the
             // "<page>/index.html" directly for the SSR page.
@@ -965,8 +971,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
               return resolve(true);
             }
 
-            var { pathname, query, protocol } = (0, _url2.parse)(url, true);
-
             if (!pathname || protocol) {
               if (false) {
               }
Diff for index.html
@@ -30,7 +30,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2a9df3ecdcd8c7823f34.module.js"
+      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.9a53c0354b7704786358.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -133,13 +133,13 @@
       type="module"
     ></script>
     <script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.133d5a9780b8a09594e6.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.0d9426f7161afec2141f.js"
       async=""
       crossorigin="anonymous"
       nomodule=""
     ></script>
     <script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2a9df3ecdcd8c7823f34.module.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.9a53c0354b7704786358.module.js"
       async=""
       crossorigin="anonymous"
       type="module"
Diff for link.html
@@ -30,7 +30,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2a9df3ecdcd8c7823f34.module.js"
+      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.9a53c0354b7704786358.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -138,13 +138,13 @@
       type="module"
     ></script>
     <script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.133d5a9780b8a09594e6.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.0d9426f7161afec2141f.js"
       async=""
       crossorigin="anonymous"
       nomodule=""
     ></script>
     <script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2a9df3ecdcd8c7823f34.module.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.9a53c0354b7704786358.module.js"
       async=""
       crossorigin="anonymous"
       type="module"
Diff for withRouter.html
@@ -30,7 +30,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2a9df3ecdcd8c7823f34.module.js"
+      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.9a53c0354b7704786358.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -133,13 +133,13 @@
       type="module"
     ></script>
     <script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.133d5a9780b8a09594e6.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.0d9426f7161afec2141f.js"
       async=""
       crossorigin="anonymous"
       nomodule=""
     ></script>
     <script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2a9df3ecdcd8c7823f34.module.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.9a53c0354b7704786358.module.js"
       async=""
       crossorigin="anonymous"
       type="module"

Serverless Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
buildDuration 13.1s 12.8s -246ms
nodeModulesSize 66 MB 66 MB ⚠️ +236 B
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
main-HASH.js gzip 6.61 kB 6.61 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..6c2a.js gzip 10.5 kB N/A N/A
framework.HASH.js gzip 39.1 kB 39.1 kB
de003c3a9d30..9545.js gzip N/A 10.5 kB N/A
Overall change 57 kB 57 kB ⚠️ +1 B
Client Bundles (main, webpack, commons) Modern Overall decrease ✓
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
main-HASH.module.js gzip 5.69 kB 5.69 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.93 kB N/A N/A
framework.HA..dule.js gzip 39.1 kB 39.1 kB
de003c3a9d30..dule.js gzip N/A 6.92 kB N/A
Overall change 52.5 kB 52.5 kB -1 B
Legacy Client Bundles (polyfills)
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_app.js gzip 1.26 kB 1.26 kB
_error.js gzip 3.25 kB 3.25 kB
hooks.js gzip 881 B 881 B
index.js gzip 222 B 222 B
link.js gzip 2.05 kB 2.05 kB
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 8.21 kB 8.21 kB
Client Pages Modern
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_app.module.js gzip 604 B 604 B
_error.module.js gzip 2.04 kB 2.04 kB
hooks.module.js gzip 383 B 383 B
index.module.js gzip 223 B 223 B
link.module.js gzip 1.51 kB 1.51 kB
routerDirect..dule.js gzip 281 B 281 B
withRouter.m..dule.js gzip 278 B 278 B
Overall change 5.32 kB 5.32 kB
Client Build Manifests
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Serverless bundles Overall increase ⚠️
vercel/next.js canary tywmick/next.js fix-dev-basepath Change
_error.js 878 kB 878 kB
404.html 4.18 kB 4.18 kB
hooks.html 3.81 kB 3.81 kB
index.js 878 kB 878 kB
link.js 916 kB 916 kB ⚠️ +103 B
routerDirect.js 909 kB 909 kB ⚠️ +103 B
withRouter.js 909 kB 909 kB ⚠️ +103 B
Overall change 4.5 MB 4.5 MB ⚠️ +309 B

@kodiakhq kodiakhq bot merged commit c33757f into vercel:canary Jun 5, 2020
@TyMick TyMick deleted the fix-dev-basepath branch June 5, 2020 17:50
@daveskybet
Copy link

Question/possible bug with the latest commit on this branch.

The previous solution worked fine for me with catch-all routes and basePath (see earlier comment), but with the later commit I now get incompatible-href-as errors with router.push, as the as value gets basePath added but href does not.

Example

router.push('/section/[...slug]', '/section/success')

results in the error

Error: The provided `as` value (/basepath/section/success) is incompatible with the `href` value (/section/[...slug])

Assuming this a bug unless I'm missing something?

@TyMick TyMick restored the fix-dev-basepath branch June 9, 2020 17:04
rokinsky pushed a commit to rokinsky/next.js that referenced this pull request Jul 11, 2020
So I can't *entirely* explain why, but I believe this fixes vercel#13132. 🙈 I basically ended up looking around at other `_next` URLs (are those asset URLs?) around the project and seeing that they tended to use `delBasePath()` to remove the base path from the current page's path whenever it was used.

When testing locally with the [repo submitted with the issue](https://github.com/robertovg/next-base-path-example), I no longer experience the constant page-reloading in dev mode when adding a query string to the URL.
@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.

Passing args in URL with experimental.basePath causes the page to constantly being reloaded.
4 participants