-
Notifications
You must be signed in to change notification settings - Fork 26.8k
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
[next] Fix to not call middleware with shallow push, fix middleware call wit… #35047
[next] Fix to not call middleware with shallow push, fix middleware call wit… #35047
Conversation
…h query parameter
const cleanedAs = delLocale( | ||
hasBasePath(options.as) ? delBasePath(options.as) : options.as, | ||
hasBasePath(asPathname) ? delBasePath(asPathname) : asPathname, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the fix for #35006
It's fixed at the same time since it's needed for the added test
Failing test suitesCommit: 49c06bd
Expand output● Router prefetch › production mode › should resolve prefetch promise with invalid href
Read more about building and testing Next.js in contributing.md. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Stats from current PRDefault Build (Increase detected
|
vercel/next.js canary | nkzawa/next.js fix-do-not-call-middleware-with-shallow-push | Change | |
---|---|---|---|
buildDuration | 15.1s | 15.1s | -35ms |
buildDurationCached | 6s | 6.1s | |
nodeModulesSize | 372 MB | 372 MB |
Page Load Tests Overall decrease ⚠️
vercel/next.js canary | nkzawa/next.js fix-do-not-call-middleware-with-shallow-push | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.914 | 2.94 | |
/ avg req/sec | 857.82 | 850.3 | |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.16 | 1.175 | |
/error-in-render avg req/sec | 2155.67 | 2127.4 |
Client Bundles (main, webpack) Overall increase ⚠️
vercel/next.js canary | nkzawa/next.js fix-do-not-call-middleware-with-shallow-push | Change | |
---|---|---|---|
925.HASH.js gzip | 179 B | 179 B | ✓ |
framework-HASH.js gzip | 42 kB | 42 kB | ✓ |
main-HASH.js gzip | 27.9 kB | 27.9 kB | |
webpack-HASH.js gzip | 1.44 kB | 1.44 kB | ✓ |
Overall change | 71.5 kB | 71.5 kB |
Legacy Client Bundles (polyfills)
vercel/next.js canary | nkzawa/next.js fix-do-not-call-middleware-with-shallow-push | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages
vercel/next.js canary | nkzawa/next.js fix-do-not-call-middleware-with-shallow-push | Change | |
---|---|---|---|
_app-HASH.js gzip | 1.36 kB | 1.36 kB | ✓ |
_error-HASH.js gzip | 192 B | 192 B | ✓ |
amp-HASH.js gzip | 309 B | 309 B | ✓ |
css-HASH.js gzip | 327 B | 327 B | ✓ |
dynamic-HASH.js gzip | 2.57 kB | 2.57 kB | ✓ |
head-HASH.js gzip | 351 B | 351 B | ✓ |
hooks-HASH.js gzip | 920 B | 920 B | ✓ |
image-HASH.js gzip | 5.09 kB | 5.09 kB | ✓ |
index-HASH.js gzip | 263 B | 263 B | ✓ |
link-HASH.js gzip | 2.26 kB | 2.26 kB | ✓ |
routerDirect..HASH.js gzip | 320 B | 320 B | ✓ |
script-HASH.js gzip | 387 B | 387 B | ✓ |
withRouter-HASH.js gzip | 319 B | 319 B | ✓ |
85e02e95b279..7e3.css gzip | 107 B | 107 B | ✓ |
Overall change | 14.8 kB | 14.8 kB | ✓ |
Client Build Manifests
vercel/next.js canary | nkzawa/next.js fix-do-not-call-middleware-with-shallow-push | Change | |
---|---|---|---|
_buildManifest.js gzip | 460 B | 460 B | ✓ |
Overall change | 460 B | 460 B | ✓ |
Rendered Page Sizes Overall decrease ✓
vercel/next.js canary | nkzawa/next.js fix-do-not-call-middleware-with-shallow-push | Change | |
---|---|---|---|
index.html gzip | 531 B | 530 B | -1 B |
link.html gzip | 545 B | 544 B | -1 B |
withRouter.html gzip | 526 B | 524 B | -2 B |
Overall change | 1.6 kB | 1.6 kB | -4 B |
Diffs
Diff for main-HASH.js
@@ -5302,13 +5302,14 @@
);
if (
!(
- options._h !== 1 ||
- (0, _isDynamic).isDynamicRoute(
- (0,
- _normalizeTrailingSlash).removePathTrailingSlash(
- pathname
- )
- )
+ (!options.shallow || options._h === 1) &&
+ (options._h !== 1 ||
+ (0, _isDynamic).isDynamicRoute(
+ (0,
+ _normalizeTrailingSlash).removePathTrailingSlash(
+ pathname
+ )
+ ))
)
) {
_ctx.next = 96;
@@ -6371,7 +6372,8 @@
var _this = this;
return _asyncToGenerator(
_runtimeJs.default.mark(function _callee() {
- var cleanedAs,
+ var asPathname,
+ cleanedAs,
fns,
requiresPreflight,
preflight,
@@ -6387,15 +6389,16 @@
while (1)
switch ((_ctx.prev = _ctx.next)) {
case 0:
+ asPathname = pathNoQueryHash(options.as);
cleanedAs = delLocale(
- hasBasePath(options.as)
- ? delBasePath(options.as)
- : options.as,
+ hasBasePath(asPathname)
+ ? delBasePath(asPathname)
+ : asPathname,
options.locale
);
- _ctx.next = 3;
+ _ctx.next = 4;
return _this.pageLoader.getMiddlewareList();
- case 3:
+ case 4:
fns = _ctx.sent;
requiresPreflight = fns.some(function(param) {
var _param = _slicedToArray(param, 2),
@@ -6409,34 +6412,34 @@
)(cleanedAs);
});
if (requiresPreflight) {
- _ctx.next = 7;
+ _ctx.next = 8;
break;
}
return _ctx.abrupt("return", {
type: "next"
});
- case 7:
- _ctx.next = 9;
+ case 8:
+ _ctx.next = 10;
return _this._getPreflightData({
preflightHref: options.as,
shouldCache: options.cache,
isPreview: options.isPreview
});
- case 9:
+ case 10:
preflight = _ctx.sent;
if (!preflight.rewrite) {
- _ctx.next = 19;
+ _ctx.next = 20;
break;
}
if (preflight.rewrite.startsWith("/")) {
- _ctx.next = 13;
+ _ctx.next = 14;
break;
}
return _ctx.abrupt("return", {
type: "redirect",
destination: options.as
});
- case 13:
+ case 14:
parsed = (0, _parseRelativeUrl).parseRelativeUrl(
(0, _normalizeLocalePath).normalizeLocalePath(
hasBasePath(preflight.rewrite)
@@ -6471,13 +6474,13 @@
matchedPage: matchedPage,
resolvedHref: resolvedHref
});
- case 19:
+ case 20:
if (!preflight.redirect) {
- _ctx.next = 25;
+ _ctx.next = 26;
break;
}
if (!preflight.redirect.startsWith("/")) {
- _ctx.next = 24;
+ _ctx.next = 25;
break;
}
cleanRedirect = (0,
@@ -6501,24 +6504,24 @@
newUrl: newUrl,
newAs: newAs
});
- case 24:
+ case 25:
return _ctx.abrupt("return", {
type: "redirect",
destination: preflight.redirect
});
- case 25:
+ case 26:
if (!(preflight.refresh && !preflight.ssr)) {
- _ctx.next = 27;
+ _ctx.next = 28;
break;
}
return _ctx.abrupt("return", {
type: "refresh"
});
- case 27:
+ case 28:
return _ctx.abrupt("return", {
type: "next"
});
- case 28:
+ case 29:
case "end":
return _ctx.stop();
}
Diff for index.html
@@ -19,7 +19,7 @@
defer=""
></script>
<script
- src="/_next/static/chunks/main-a9622e10c1f28000.js"
+ src="/_next/static/chunks/main-5ef02dfc5c89364b.js"
defer=""
></script>
<script
Diff for link.html
@@ -19,7 +19,7 @@
defer=""
></script>
<script
- src="/_next/static/chunks/main-a9622e10c1f28000.js"
+ src="/_next/static/chunks/main-5ef02dfc5c89364b.js"
defer=""
></script>
<script
Diff for withRouter.html
@@ -19,7 +19,7 @@
defer=""
></script>
<script
- src="/_next/static/chunks/main-a9622e10c1f28000.js"
+ src="/_next/static/chunks/main-5ef02dfc5c89364b.js"
defer=""
></script>
<script
Default Build with SWC (Increase detected ⚠️ )
General Overall increase ⚠️
vercel/next.js canary | nkzawa/next.js fix-do-not-call-middleware-with-shallow-push | Change | |
---|---|---|---|
buildDuration | 18.4s | 18.5s | |
buildDurationCached | 6s | 6s | |
nodeModulesSize | 372 MB | 372 MB |
Page Load Tests Overall increase ✓
vercel/next.js canary | nkzawa/next.js fix-do-not-call-middleware-with-shallow-push | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.924 | 2.921 | 0 |
/ avg req/sec | 854.95 | 855.91 | +0.96 |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.2 | 1.199 | 0 |
/error-in-render avg req/sec | 2082.97 | 2085.43 | +2.46 |
Client Bundles (main, webpack) Overall increase ⚠️
vercel/next.js canary | nkzawa/next.js fix-do-not-call-middleware-with-shallow-push | Change | |
---|---|---|---|
925.HASH.js gzip | 178 B | 178 B | ✓ |
framework-HASH.js gzip | 42.3 kB | 42.3 kB | ✓ |
main-HASH.js gzip | 28.2 kB | 28.2 kB | |
webpack-HASH.js gzip | 1.45 kB | 1.45 kB | ✓ |
Overall change | 72.1 kB | 72.1 kB |
Legacy Client Bundles (polyfills)
vercel/next.js canary | nkzawa/next.js fix-do-not-call-middleware-with-shallow-push | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages
vercel/next.js canary | nkzawa/next.js fix-do-not-call-middleware-with-shallow-push | Change | |
---|---|---|---|
_app-HASH.js gzip | 1.35 kB | 1.35 kB | ✓ |
_error-HASH.js gzip | 179 B | 179 B | ✓ |
amp-HASH.js gzip | 313 B | 313 B | ✓ |
css-HASH.js gzip | 324 B | 324 B | ✓ |
dynamic-HASH.js gzip | 2.56 kB | 2.56 kB | ✓ |
head-HASH.js gzip | 351 B | 351 B | ✓ |
hooks-HASH.js gzip | 921 B | 921 B | ✓ |
image-HASH.js gzip | 5.23 kB | 5.23 kB | ✓ |
index-HASH.js gzip | 261 B | 261 B | ✓ |
link-HASH.js gzip | 2.33 kB | 2.33 kB | ✓ |
routerDirect..HASH.js gzip | 322 B | 322 B | ✓ |
script-HASH.js gzip | 388 B | 388 B | ✓ |
withRouter-HASH.js gzip | 317 B | 317 B | ✓ |
85e02e95b279..7e3.css gzip | 107 B | 107 B | ✓ |
Overall change | 15 kB | 15 kB | ✓ |
Client Build Manifests
vercel/next.js canary | nkzawa/next.js fix-do-not-call-middleware-with-shallow-push | Change | |
---|---|---|---|
_buildManifest.js gzip | 459 B | 459 B | ✓ |
Overall change | 459 B | 459 B | ✓ |
Rendered Page Sizes Overall increase ⚠️
vercel/next.js canary | nkzawa/next.js fix-do-not-call-middleware-with-shallow-push | Change | |
---|---|---|---|
index.html gzip | 530 B | 532 B | |
link.html gzip | 544 B | 546 B | |
withRouter.html gzip | 525 B | 527 B | |
Overall change | 1.6 kB | 1.6 kB |
Diffs
Diff for main-HASH.js
@@ -5302,13 +5302,14 @@
);
if (
!(
- options._h !== 1 ||
- (0, _isDynamic).isDynamicRoute(
- (0,
- _normalizeTrailingSlash).removePathTrailingSlash(
- pathname
- )
- )
+ (!options.shallow || options._h === 1) &&
+ (options._h !== 1 ||
+ (0, _isDynamic).isDynamicRoute(
+ (0,
+ _normalizeTrailingSlash).removePathTrailingSlash(
+ pathname
+ )
+ ))
)
) {
_ctx.next = 96;
@@ -6371,7 +6372,8 @@
var _this = this;
return _asyncToGenerator(
_runtimeJs.default.mark(function _callee() {
- var cleanedAs,
+ var asPathname,
+ cleanedAs,
fns,
requiresPreflight,
preflight,
@@ -6387,15 +6389,16 @@
while (1)
switch ((_ctx.prev = _ctx.next)) {
case 0:
+ asPathname = pathNoQueryHash(options.as);
cleanedAs = delLocale(
- hasBasePath(options.as)
- ? delBasePath(options.as)
- : options.as,
+ hasBasePath(asPathname)
+ ? delBasePath(asPathname)
+ : asPathname,
options.locale
);
- _ctx.next = 3;
+ _ctx.next = 4;
return _this.pageLoader.getMiddlewareList();
- case 3:
+ case 4:
fns = _ctx.sent;
requiresPreflight = fns.some(function(param) {
var _param = _slicedToArray(param, 2),
@@ -6409,34 +6412,34 @@
)(cleanedAs);
});
if (requiresPreflight) {
- _ctx.next = 7;
+ _ctx.next = 8;
break;
}
return _ctx.abrupt("return", {
type: "next"
});
- case 7:
- _ctx.next = 9;
+ case 8:
+ _ctx.next = 10;
return _this._getPreflightData({
preflightHref: options.as,
shouldCache: options.cache,
isPreview: options.isPreview
});
- case 9:
+ case 10:
preflight = _ctx.sent;
if (!preflight.rewrite) {
- _ctx.next = 19;
+ _ctx.next = 20;
break;
}
if (preflight.rewrite.startsWith("/")) {
- _ctx.next = 13;
+ _ctx.next = 14;
break;
}
return _ctx.abrupt("return", {
type: "redirect",
destination: options.as
});
- case 13:
+ case 14:
parsed = (0, _parseRelativeUrl).parseRelativeUrl(
(0, _normalizeLocalePath).normalizeLocalePath(
hasBasePath(preflight.rewrite)
@@ -6471,13 +6474,13 @@
matchedPage: matchedPage,
resolvedHref: resolvedHref
});
- case 19:
+ case 20:
if (!preflight.redirect) {
- _ctx.next = 25;
+ _ctx.next = 26;
break;
}
if (!preflight.redirect.startsWith("/")) {
- _ctx.next = 24;
+ _ctx.next = 25;
break;
}
cleanRedirect = (0,
@@ -6501,24 +6504,24 @@
newUrl: newUrl,
newAs: newAs
});
- case 24:
+ case 25:
return _ctx.abrupt("return", {
type: "redirect",
destination: preflight.redirect
});
- case 25:
+ case 26:
if (!(preflight.refresh && !preflight.ssr)) {
- _ctx.next = 27;
+ _ctx.next = 28;
break;
}
return _ctx.abrupt("return", {
type: "refresh"
});
- case 27:
+ case 28:
return _ctx.abrupt("return", {
type: "next"
});
- case 28:
+ case 29:
case "end":
return _ctx.stop();
}
Diff for index.html
@@ -19,7 +19,7 @@
defer=""
></script>
<script
- src="/_next/static/chunks/main-a9622e10c1f28000.js"
+ src="/_next/static/chunks/main-5ef02dfc5c89364b.js"
defer=""
></script>
<script
Diff for link.html
@@ -19,7 +19,7 @@
defer=""
></script>
<script
- src="/_next/static/chunks/main-a9622e10c1f28000.js"
+ src="/_next/static/chunks/main-5ef02dfc5c89364b.js"
defer=""
></script>
<script
Diff for withRouter.html
@@ -19,7 +19,7 @@
defer=""
></script>
<script
- src="/_next/static/chunks/main-a9622e10c1f28000.js"
+ src="/_next/static/chunks/main-5ef02dfc5c89364b.js"
defer=""
></script>
<script
…h query parameter
Fixes #32655 and fixes #35006
Bug
fixes #number
contributing.md