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

Change default of prerenderEarlyExit to true #65830

Merged
merged 3 commits into from
May 20, 2024

Conversation

ijjk
Copy link
Member

@ijjk ijjk commented May 16, 2024

Background

Historically during prerendering we have waiting until all paths have been attempted before we exit the process and fail the build. This is nice if you want to collect all potential errors to address them at the same time although this has the drawback of slowing down builds if things are timing out or if the same error is occurring across numerous paths.

New Behavior

This changes our default behavior to immediately exit when the first error occurs during prerendering so that builds don't stall out from timeout errors or from the same error occurring across numerous paths. This will help from holding up CI or similar un-necessarily.

If users want to opt-in to the previous behavior the flag is still present under experimental.prerenderEarlyExit.

@ijjk ijjk added created-by: Next.js team PRs by the Next.js team type: next labels May 16, 2024
@ijjk ijjk marked this pull request as draft May 16, 2024 00:47
@ijjk
Copy link
Member Author

ijjk commented May 16, 2024

Stats from current PR

Default Build (Increase detected ⚠️)
General
vercel/next.js canary vercel/next.js ijjk/update/prerender-early-exit Change
buildDuration 16.8s 14.2s N/A
buildDurationCached 9s 7.5s N/A
nodeModulesSize 345 MB 345 MB N/A
nextStartRea..uration (ms) 410ms 413ms N/A
Client Bundles (main, webpack)
vercel/next.js canary vercel/next.js ijjk/update/prerender-early-exit Change
1813.HASH.js gzip 169 B 169 B
3433-HASH.js gzip 5.06 kB 5.06 kB N/A
6159-HASH.js gzip 33.6 kB 33.6 kB N/A
69089819-HASH.js gzip 50.8 kB 50.8 kB N/A
framework-HASH.js gzip 55.8 kB 55.8 kB N/A
main-app-HASH.js gzip 218 B 221 B N/A
main-HASH.js gzip 32.3 kB 32.3 kB N/A
webpack-HASH.js gzip 1.71 kB 1.7 kB N/A
Overall change 169 B 169 B
Legacy Client Bundles (polyfills)
vercel/next.js canary vercel/next.js ijjk/update/prerender-early-exit Change
polyfills-HASH.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary vercel/next.js ijjk/update/prerender-early-exit Change
_app-HASH.js gzip 192 B 193 B N/A
_error-HASH.js gzip 192 B 192 B
amp-HASH.js gzip 511 B 510 B N/A
css-HASH.js gzip 342 B 343 B N/A
dynamic-HASH.js gzip 2.53 kB 2.52 kB N/A
edge-ssr-HASH.js gzip 265 B 266 B N/A
head-HASH.js gzip 362 B 364 B N/A
hooks-HASH.js gzip 391 B 392 B N/A
image-HASH.js gzip 4.27 kB 4.27 kB N/A
index-HASH.js gzip 269 B 268 B N/A
link-HASH.js gzip 2.69 kB 2.69 kB N/A
routerDirect..HASH.js gzip 328 B 329 B N/A
script-HASH.js gzip 394 B 397 B N/A
withRouter-HASH.js gzip 324 B 324 B
1afbb74e6ecf..834.css gzip 106 B 106 B
Overall change 622 B 622 B
Client Build Manifests
vercel/next.js canary vercel/next.js ijjk/update/prerender-early-exit Change
_buildManifest.js gzip 483 B 483 B
Overall change 483 B 483 B
Rendered Page Sizes
vercel/next.js canary vercel/next.js ijjk/update/prerender-early-exit Change
index.html gzip 522 B 522 B
link.html gzip 535 B 536 B N/A
withRouter.html gzip 518 B 518 B
Overall change 1.04 kB 1.04 kB
Edge SSR bundle Size
vercel/next.js canary vercel/next.js ijjk/update/prerender-early-exit Change
edge-ssr.js gzip 121 kB 121 kB N/A
page.js gzip 179 kB 179 kB N/A
Overall change 0 B 0 B
Middleware size
vercel/next.js canary vercel/next.js ijjk/update/prerender-early-exit Change
middleware-b..fest.js gzip 657 B 656 B N/A
middleware-r..fest.js gzip 155 B 153 B N/A
middleware.js gzip 25.8 kB 25.8 kB N/A
edge-runtime..pack.js gzip 839 B 839 B
Overall change 839 B 839 B
Next Runtimes
vercel/next.js canary vercel/next.js ijjk/update/prerender-early-exit Change
app-page-exp...dev.js gzip 174 kB 174 kB
app-page-exp..prod.js gzip 106 kB 106 kB
app-page-tur..prod.js gzip 115 kB 115 kB
app-page-tur..prod.js gzip 94.5 kB 94.5 kB
app-page.run...dev.js gzip 160 kB 160 kB
app-page.run..prod.js gzip 93.2 kB 93.2 kB
app-route-ex...dev.js gzip 21.1 kB 21.1 kB
app-route-ex..prod.js gzip 15 kB 15 kB
app-route-tu..prod.js gzip 15 kB 15 kB
app-route-tu..prod.js gzip 14.8 kB 14.8 kB
app-route.ru...dev.js gzip 20.9 kB 20.9 kB
app-route.ru..prod.js gzip 14.8 kB 14.8 kB
pages-api-tu..prod.js gzip 9.55 kB 9.55 kB
pages-api.ru...dev.js gzip 9.82 kB 9.82 kB
pages-api.ru..prod.js gzip 9.55 kB 9.55 kB
pages-turbo...prod.js gzip 21.5 kB 21.5 kB
pages.runtim...dev.js gzip 22.1 kB 22.1 kB
pages.runtim..prod.js gzip 21.5 kB 21.5 kB
server.runti..prod.js gzip 52.2 kB 52.2 kB
Overall change 989 kB 989 kB
build cache Overall increase ⚠️
vercel/next.js canary vercel/next.js ijjk/update/prerender-early-exit Change
0.pack gzip 1.65 MB 1.65 MB ⚠️ +1.34 kB
index.pack gzip 126 kB 126 kB ⚠️ +266 B
Overall change 1.77 MB 1.77 MB ⚠️ +1.61 kB
Diff details
Diff for page.js

Diff too large to display

Diff for middleware.js

Diff too large to display

Diff for edge-ssr.js

Diff too large to display

Diff for image-HASH.js
@@ -1,7 +1,7 @@
 (self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([
   [8358],
   {
-    /***/ 5497: /***/ (
+    /***/ 2307: /***/ (
       __unused_webpack_module,
       __unused_webpack_exports,
       __webpack_require__
@@ -9,7 +9,7 @@
       (window.__NEXT_P = window.__NEXT_P || []).push([
         "/image",
         function () {
-          return __webpack_require__(5700);
+          return __webpack_require__(4720);
         },
       ]);
       if (false) {
@@ -18,7 +18,7 @@
       /***/
     },
 
-    /***/ 959: /***/ (module, exports, __webpack_require__) => {
+    /***/ 8697: /***/ (module, exports, __webpack_require__) => {
       "use strict";
       /* __next_internal_client_entry_do_not_use__  cjs */
       Object.defineProperty(exports, "__esModule", {
@@ -40,15 +40,15 @@
         __webpack_require__(5439)
       );
       const _head = /*#__PURE__*/ _interop_require_default._(
-        __webpack_require__(232)
+        __webpack_require__(2185)
       );
-      const _getimgprops = __webpack_require__(7335);
-      const _imageconfig = __webpack_require__(7712);
-      const _imageconfigcontextsharedruntime = __webpack_require__(1207);
-      const _warnonce = __webpack_require__(9114);
-      const _routercontextsharedruntime = __webpack_require__(8426);
+      const _getimgprops = __webpack_require__(9461);
+      const _imageconfig = __webpack_require__(5517);
+      const _imageconfigcontextsharedruntime = __webpack_require__(8947);
+      const _warnonce = __webpack_require__(5860);
+      const _routercontextsharedruntime = __webpack_require__(7328);
       const _imageloader = /*#__PURE__*/ _interop_require_default._(
-        __webpack_require__(8106)
+        __webpack_require__(7310)
       );
       // This is replaced by webpack define plugin
       const configEnv = {
@@ -376,7 +376,7 @@
       /***/
     },
 
-    /***/ 7335: /***/ (
+    /***/ 9461: /***/ (
       __unused_webpack_module,
       exports,
       __webpack_require__
@@ -392,9 +392,9 @@
           return getImgProps;
         },
       });
-      const _warnonce = __webpack_require__(9114);
-      const _imageblursvg = __webpack_require__(9966);
-      const _imageconfig = __webpack_require__(7712);
+      const _warnonce = __webpack_require__(5860);
+      const _imageblursvg = __webpack_require__(5425);
+      const _imageconfig = __webpack_require__(5517);
       const VALID_LOADING_VALUES =
         /* unused pure expression or super */ null && [
           "lazy",
@@ -769,7 +769,7 @@
       /***/
     },
 
-    /***/ 9966: /***/ (__unused_webpack_module, exports) => {
+    /***/ 5425: /***/ (__unused_webpack_module, exports) => {
       "use strict";
       /**
        * A shared function, used on both client and server, to generate a SVG blur placeholder.
@@ -824,7 +824,7 @@
       /***/
     },
 
-    /***/ 8366: /***/ (
+    /***/ 9578: /***/ (
       __unused_webpack_module,
       exports,
       __webpack_require__
@@ -851,10 +851,10 @@
         },
       });
       const _interop_require_default = __webpack_require__(1478);
-      const _getimgprops = __webpack_require__(7335);
-      const _imagecomponent = __webpack_require__(959);
+      const _getimgprops = __webpack_require__(9461);
+      const _imagecomponent = __webpack_require__(8697);
       const _imageloader = /*#__PURE__*/ _interop_require_default._(
-        __webpack_require__(8106)
+        __webpack_require__(7310)
       );
       function getImageProps(imgProps) {
         const { props } = (0, _getimgprops.getImgProps)(imgProps, {
@@ -886,7 +886,7 @@
       /***/
     },
 
-    /***/ 8106: /***/ (__unused_webpack_module, exports) => {
+    /***/ 7310: /***/ (__unused_webpack_module, exports) => {
       "use strict";
 
       Object.defineProperty(exports, "__esModule", {
@@ -921,7 +921,7 @@
       /***/
     },
 
-    /***/ 5700: /***/ (
+    /***/ 4720: /***/ (
       __unused_webpack_module,
       __webpack_exports__,
       __webpack_require__
@@ -938,8 +938,8 @@
 
       // EXTERNAL MODULE: ./node_modules/.pnpm/react@19.0.0-beta-4508873393-20240430/node_modules/react/jsx-runtime.js
       var jsx_runtime = __webpack_require__(3456);
-      // EXTERNAL MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-beta-4508873393-20240430_rea_65yyqpgvftv4sckwrae5ytuiki/node_modules/next/image.js
-      var next_image = __webpack_require__(5008);
+      // EXTERNAL MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-beta-4508873393-20240430_rea_bi4li5t763kdoqq4snruxkmfcu/node_modules/next/image.js
+      var next_image = __webpack_require__(932);
       var image_default = /*#__PURE__*/ __webpack_require__.n(next_image); // CONCATENATED MODULE: ./pages/nextjs.png
       /* harmony default export */ const nextjs = {
         src: "/_next/static/media/nextjs.cae0b805.png",
@@ -969,12 +969,12 @@
       /***/
     },
 
-    /***/ 5008: /***/ (
+    /***/ 932: /***/ (
       module,
       __unused_webpack_exports,
       __webpack_require__
     ) => {
-      module.exports = __webpack_require__(8366);
+      module.exports = __webpack_require__(9578);
 
       /***/
     },
@@ -984,7 +984,7 @@
     /******/ var __webpack_exec__ = (moduleId) =>
       __webpack_require__((__webpack_require__.s = moduleId));
     /******/ __webpack_require__.O(0, [2888, 9774, 179], () =>
-      __webpack_exec__(5497)
+      __webpack_exec__(2307)
     );
     /******/ var __webpack_exports__ = __webpack_require__.O();
     /******/ _N_E = __webpack_exports__;
Diff for main-HASH.js

Diff too large to display

Commit: dd12fa5

@ijjk ijjk added the tests label May 16, 2024
@ijjk ijjk marked this pull request as ready for review May 16, 2024 18:38
@ijjk ijjk merged commit c5a0878 into canary May 20, 2024
79 of 80 checks passed
@ijjk ijjk deleted the ijjk/update/prerender-early-exit branch May 20, 2024 19:51
ijjk pushed a commit that referenced this pull request May 21, 2024
Since, #65830, I've been seeing
weird flakes from
`test/e2e/app-dir/app-invalid-revalidate/app-invalid-revalidate.test.ts`.
```
TIMED OUT: /Invalid revalidate value "1" on "\/", must be a non-negative number or "false"/
```

The build output looks like this:

```
  ▲ Next.js 14.3.0-canary.73

   Creating an optimized production build ...
   
[snip]

Error: Invalid revalidate value "1" on "/_not-found", must be a non-negative number or "false"

[snip]

     Generating static pages (2/4) 
  > Build error occurred
  Error: Export encountered an error on /_not-found, exiting due to prerenderEarlyExit: true being set
```
Note that there's no `Invalid revalidate value "1"` message for `/`, so
the test will fail.

This looks like a race condition: the invalid `revalidate` value is set
in a layout, so if `_not-found` happens to be prerendered before `/`,
it'll abort the whole prerender (because of `prerenderEarlyExit: true`).
so if the timing is right, the test -- which is looking for build errors
for `/` -- will never see them and time out.

There might be more of these, but unfortunately they're basically race
conditions, so I think we'll have to squash them as they come up.

CC @ijjk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants