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

feat(turbopack): Add an env var to debug-print the fast refresh invalidation reason #72296

Merged
merged 1 commit into from
Nov 5, 2024

Conversation

bgw
Copy link
Member

@bgw bgw commented Nov 4, 2024

Setting the environment variable when building (next dev)

NEXT_TURBOPACK_INCLUDE_UPDATE_REASONS=1

causes [Update Reasons] messages to be logged to the terminal console (not in the browser) when a file is changed:

Screenshot 2024-11-04 at 4.31.16 PM.png

These messages will not appear if no reason was recorded when the invalidation happened, so this provided on a best-effort basis.

Why? The hope is that this can help debug cases where users get stuck in a fast refresh update loop: https://vercel.slack.com/archives/C03S8ED1DKM/p1730737898652749

Closes PACK-3374

@ijjk ijjk added created-by: Turbopack team PRs by the Turbopack team. type: next labels Nov 4, 2024
Copy link
Member Author

bgw commented Nov 4, 2024

@ijjk
Copy link
Member

ijjk commented Nov 4, 2024

Stats from current PR

Default Build
General
vercel/next.js canary vercel/next.js bgw/invalidation-reason-debug Change
buildDuration 19.1s 19s N/A
buildDurationCached 16.7s 14.7s N/A
nodeModulesSize 403 MB 403 MB N/A
nextStartRea..uration (ms) 473ms 478ms N/A
Client Bundles (main, webpack)
vercel/next.js canary vercel/next.js bgw/invalidation-reason-debug Change
3073-HASH.js gzip 45.4 kB 45.4 kB N/A
3898-HASH.js gzip 5.27 kB 5.27 kB N/A
7183.HASH.js gzip 169 B 169 B
b5cfd723-HASH.js gzip 52.5 kB 52.5 kB N/A
framework-HASH.js gzip 57.3 kB 57.3 kB N/A
main-app-HASH.js gzip 236 B 231 B N/A
main-HASH.js gzip 33.1 kB 33.1 kB N/A
webpack-HASH.js gzip 1.71 kB 1.71 kB N/A
Overall change 169 B 169 B
Legacy Client Bundles (polyfills)
vercel/next.js canary vercel/next.js bgw/invalidation-reason-debug Change
polyfills-HASH.js gzip 39.4 kB 39.4 kB
Overall change 39.4 kB 39.4 kB
Client Pages
vercel/next.js canary vercel/next.js bgw/invalidation-reason-debug Change
_app-HASH.js gzip 193 B 193 B
_error-HASH.js gzip 192 B 192 B
amp-HASH.js gzip 513 B 508 B N/A
css-HASH.js gzip 343 B 343 B
dynamic-HASH.js gzip 1.85 kB 1.84 kB N/A
edge-ssr-HASH.js gzip 265 B 264 B N/A
head-HASH.js gzip 363 B 365 B N/A
hooks-HASH.js gzip 392 B 391 B N/A
image-HASH.js gzip 4.41 kB 4.41 kB
index-HASH.js gzip 268 B 268 B
link-HASH.js gzip 2.77 kB 2.77 kB N/A
routerDirect..HASH.js gzip 327 B 327 B
script-HASH.js gzip 396 B 394 B N/A
withRouter-HASH.js gzip 324 B 322 B N/A
1afbb74e6ecf..834.css gzip 106 B 106 B
Overall change 5.84 kB 5.84 kB
Client Build Manifests
vercel/next.js canary vercel/next.js bgw/invalidation-reason-debug Change
_buildManifest.js gzip 748 B 750 B N/A
Overall change 0 B 0 B
Rendered Page Sizes
vercel/next.js canary vercel/next.js bgw/invalidation-reason-debug Change
index.html gzip 524 B 524 B
link.html gzip 539 B 539 B
withRouter.html gzip 519 B 519 B
Overall change 1.58 kB 1.58 kB
Edge SSR bundle Size
vercel/next.js canary vercel/next.js bgw/invalidation-reason-debug Change
edge-ssr.js gzip 128 kB 128 kB N/A
page.js gzip 198 kB 189 kB N/A
Overall change 0 B 0 B
Middleware size
vercel/next.js canary vercel/next.js bgw/invalidation-reason-debug Change
middleware-b..fest.js gzip 668 B 668 B
middleware-r..fest.js gzip 156 B 155 B N/A
middleware.js gzip 31 kB 31 kB N/A
edge-runtime..pack.js gzip 844 B 844 B
Overall change 1.51 kB 1.51 kB
Next Runtimes
vercel/next.js canary vercel/next.js bgw/invalidation-reason-debug Change
10-experimen...dev.js gzip 319 B N/A N/A
10.runtime.dev.js gzip 311 B N/A N/A
app-page-exp...dev.js gzip 318 kB 318 kB N/A
app-page-exp..prod.js gzip 123 kB 122 kB N/A
app-page-tur..prod.js gzip 136 kB 135 kB N/A
app-page-tur..prod.js gzip 131 kB 130 kB N/A
app-page.run...dev.js gzip 309 kB 308 kB N/A
app-page.run..prod.js gzip 119 kB 118 kB N/A
app-route-ex...dev.js gzip 35.9 kB 35.9 kB N/A
app-route-ex..prod.js gzip 24.4 kB 24.3 kB N/A
app-route-tu..prod.js gzip 24.4 kB 24.4 kB N/A
app-route-tu..prod.js gzip 24.2 kB 24.1 kB N/A
app-route.ru...dev.js gzip 37.5 kB 37.5 kB N/A
app-route.ru..prod.js gzip 24.2 kB 24.1 kB N/A
pages-api-tu..prod.js gzip 9.59 kB 9.59 kB
pages-api.ru...dev.js gzip 11.4 kB 11.4 kB
pages-api.ru..prod.js gzip 9.58 kB 9.58 kB
pages-turbo...prod.js gzip 20.9 kB 20.9 kB N/A
pages.runtim...dev.js gzip 26.5 kB 26.5 kB N/A
pages.runtim..prod.js gzip 20.9 kB 20.9 kB N/A
server.runti..prod.js gzip 915 kB 914 kB N/A
973-experime...dev.js gzip N/A 322 B N/A
973.runtime.dev.js gzip N/A 314 B N/A
Overall change 30.6 kB 30.6 kB
build cache
vercel/next.js canary vercel/next.js bgw/invalidation-reason-debug Change
0.pack gzip 2 MB 1.85 MB N/A
index.pack gzip 146 kB 144 kB N/A
Overall change 0 B 0 B
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([
-  [2983],
+  [8358],
   {
-    /***/ 8916: /***/ (
+    /***/ 8942: /***/ (
       __unused_webpack_module,
       __unused_webpack_exports,
       __webpack_require__
@@ -9,7 +9,7 @@
       (window.__NEXT_P = window.__NEXT_P || []).push([
         "/image",
         function () {
-          return __webpack_require__(4209);
+          return __webpack_require__(2864);
         },
       ]);
       if (false) {
@@ -18,7 +18,7 @@
       /***/
     },
 
-    /***/ 9265: /***/ (module, exports, __webpack_require__) => {
+    /***/ 1673: /***/ (module, exports, __webpack_require__) => {
       "use strict";
       /* __next_internal_client_entry_do_not_use__  cjs */
       Object.defineProperty(exports, "__esModule", {
@@ -30,27 +30,27 @@
           return Image;
         },
       });
-      const _interop_require_default = __webpack_require__(1739);
-      const _interop_require_wildcard = __webpack_require__(1474);
-      const _jsxruntime = __webpack_require__(7515);
+      const _interop_require_default = __webpack_require__(9608);
+      const _interop_require_wildcard = __webpack_require__(4856);
+      const _jsxruntime = __webpack_require__(2073);
       const _react = /*#__PURE__*/ _interop_require_wildcard._(
-        __webpack_require__(7611)
+        __webpack_require__(102)
       );
       const _reactdom = /*#__PURE__*/ _interop_require_default._(
-        __webpack_require__(9577)
+        __webpack_require__(8693)
       );
       const _head = /*#__PURE__*/ _interop_require_default._(
-        __webpack_require__(1436)
+        __webpack_require__(5838)
       );
-      const _getimgprops = __webpack_require__(8517);
-      const _imageconfig = __webpack_require__(2168);
-      const _imageconfigcontextsharedruntime = __webpack_require__(9202);
-      const _warnonce = __webpack_require__(6992);
-      const _routercontextsharedruntime = __webpack_require__(8155);
+      const _getimgprops = __webpack_require__(5726);
+      const _imageconfig = __webpack_require__(187);
+      const _imageconfigcontextsharedruntime = __webpack_require__(5786);
+      const _warnonce = __webpack_require__(3673);
+      const _routercontextsharedruntime = __webpack_require__(759);
       const _imageloader = /*#__PURE__*/ _interop_require_default._(
-        __webpack_require__(345)
+        __webpack_require__(2182)
       );
-      const _usemergedref = __webpack_require__(2806);
+      const _usemergedref = __webpack_require__(9363);
       // This is replaced by webpack define plugin
       const configEnv = {
         deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
@@ -371,7 +371,7 @@
       /***/
     },
 
-    /***/ 2806: /***/ (module, exports, __webpack_require__) => {
+    /***/ 9363: /***/ (module, exports, __webpack_require__) => {
       "use strict";
 
       Object.defineProperty(exports, "__esModule", {
@@ -383,7 +383,7 @@
           return useMergedRef;
         },
       });
-      const _react = __webpack_require__(7611);
+      const _react = __webpack_require__(102);
       function useMergedRef(refA, refB) {
         const cleanupA = (0, _react.useRef)(() => {});
         const cleanupB = (0, _react.useRef)(() => {});
@@ -432,7 +432,7 @@
       /***/
     },
 
-    /***/ 8517: /***/ (
+    /***/ 5726: /***/ (
       __unused_webpack_module,
       exports,
       __webpack_require__
@@ -448,9 +448,9 @@
           return getImgProps;
         },
       });
-      const _warnonce = __webpack_require__(6992);
-      const _imageblursvg = __webpack_require__(1692);
-      const _imageconfig = __webpack_require__(2168);
+      const _warnonce = __webpack_require__(3673);
+      const _imageblursvg = __webpack_require__(5499);
+      const _imageconfig = __webpack_require__(187);
       const VALID_LOADING_VALUES =
         /* unused pure expression or super */ null && [
           "lazy",
@@ -824,7 +824,7 @@
       /***/
     },
 
-    /***/ 1692: /***/ (__unused_webpack_module, exports) => {
+    /***/ 5499: /***/ (__unused_webpack_module, exports) => {
       "use strict";
       /**
        * A shared function, used on both client and server, to generate a SVG blur placeholder.
@@ -879,7 +879,7 @@
       /***/
     },
 
-    /***/ 4673: /***/ (
+    /***/ 6157: /***/ (
       __unused_webpack_module,
       exports,
       __webpack_require__
@@ -905,11 +905,11 @@
           return getImageProps;
         },
       });
-      const _interop_require_default = __webpack_require__(1739);
-      const _getimgprops = __webpack_require__(8517);
-      const _imagecomponent = __webpack_require__(9265);
+      const _interop_require_default = __webpack_require__(9608);
+      const _getimgprops = __webpack_require__(5726);
+      const _imagecomponent = __webpack_require__(1673);
       const _imageloader = /*#__PURE__*/ _interop_require_default._(
-        __webpack_require__(345)
+        __webpack_require__(2182)
       );
       function getImageProps(imgProps) {
         const { props } = (0, _getimgprops.getImgProps)(imgProps, {
@@ -941,7 +941,7 @@
       /***/
     },
 
-    /***/ 345: /***/ (__unused_webpack_module, exports) => {
+    /***/ 2182: /***/ (__unused_webpack_module, exports) => {
       "use strict";
 
       Object.defineProperty(exports, "__esModule", {
@@ -976,7 +976,7 @@
       /***/
     },
 
-    /***/ 4209: /***/ (
+    /***/ 2864: /***/ (
       __unused_webpack_module,
       __webpack_exports__,
       __webpack_require__
@@ -992,10 +992,10 @@
       });
 
       // EXTERNAL MODULE: ./node_modules/.pnpm/react@19.0.0-rc-7c8e5e7a-20241101/node_modules/react/jsx-runtime.js
-      var jsx_runtime = __webpack_require__(7515);
-      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-7c8e5e7a-20241101_re_ngsqfltlxii45umrwe6rktuauy/node_modules/next/image.js
-      var next_image = __webpack_require__(7265);
-      var image_default = /*#__PURE__*/ __webpack_require__.n(next_image); // ./pages/nextjs.png
+      var jsx_runtime = __webpack_require__(2073);
+      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-7c8e5e7a-20241101_re_ay5jspqvpcpk5357qiimbatlya/node_modules/next/image.js
+      var next_image = __webpack_require__(9915);
+      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",
         height: 1347,
@@ -1004,7 +1004,7 @@
           "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAHCAMAAAACh/xsAAAAD1BMVEX////x8fH6+vrb29vo6Oh8o70bAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAH0lEQVR4nGNgwARMjIyMjCAGCzMzMwsTRISJCcRABwAEcAAkLCQfgAAAAABJRU5ErkJggg==",
         blurWidth: 8,
         blurHeight: 7,
-      }; // ./pages/image.js
+      }; // CONCATENATED MODULE: ./pages/image.js
       function ImagePage(props) {
         return /*#__PURE__*/ (0, jsx_runtime.jsxs)(jsx_runtime.Fragment, {
           children: [
@@ -1024,12 +1024,12 @@
       /***/
     },
 
-    /***/ 7265: /***/ (
+    /***/ 9915: /***/ (
       module,
       __unused_webpack_exports,
       __webpack_require__
     ) => {
-      module.exports = __webpack_require__(4673);
+      module.exports = __webpack_require__(6157);
 
       /***/
     },
@@ -1038,8 +1038,8 @@
     // webpackRuntimeModules
     /******/ var __webpack_exec__ = (moduleId) =>
       __webpack_require__((__webpack_require__.s = moduleId));
-    /******/ __webpack_require__.O(0, [636, 6593, 8792], () =>
-      __webpack_exec__(8916)
+    /******/ __webpack_require__.O(0, [2888, 9774, 179], () =>
+      __webpack_exec__(8942)
     );
     /******/ var __webpack_exports__ = __webpack_require__.O();
     /******/ _N_E = __webpack_exports__;
Diff for 3073-HASH.js

Diff too large to display

Diff for main-HASH.js

Diff too large to display

Diff for 10-experimen..ntime.dev.js
deleted
Diff for 10.runtime.dev.js
deleted
Diff for 973-experime..ntime.dev.js
@@ -0,0 +1,2 @@
+"use strict";exports.id=973,exports.ids=[973],exports.modules={"./dist/client/dev/noop-turbopack-hmr.js":(module,exports1)=>{function connect(){}Object.defineProperty(exports1,"__esModule",{value:!0}),Object.defineProperty(exports1,"connect",{enumerable:!0,get:function(){return connect}}),("function"==typeof exports1.default||"object"==typeof exports1.default&&null!==exports1.default)&&void 0===exports1.default.__esModule&&(Object.defineProperty(exports1.default,"__esModule",{value:!0}),Object.assign(exports1.default,exports1),module.exports=exports1.default)}};
+//# sourceMappingURL=973-experimental.runtime.dev.js.map
\ No newline at end of file
Diff for 973.runtime.dev.js
@@ -0,0 +1,2 @@
+"use strict";exports.id=973,exports.ids=[973],exports.modules={"./dist/client/dev/noop-turbopack-hmr.js":(module,exports1)=>{function connect(){}Object.defineProperty(exports1,"__esModule",{value:!0}),Object.defineProperty(exports1,"connect",{enumerable:!0,get:function(){return connect}}),("function"==typeof exports1.default||"object"==typeof exports1.default&&null!==exports1.default)&&void 0===exports1.default.__esModule&&(Object.defineProperty(exports1.default,"__esModule",{value:!0}),Object.assign(exports1.default,exports1),module.exports=exports1.default)}};
+//# sourceMappingURL=973.runtime.dev.js.map
\ No newline at end of file
Diff for app-page-exp..ntime.dev.js
failed to diff
Diff for app-page-exp..time.prod.js

Diff too large to display

Diff for app-page-tur..time.prod.js

Diff too large to display

Diff for app-page-tur..time.prod.js

Diff too large to display

Diff for app-page.runtime.dev.js
failed to diff
Diff for app-page.runtime.prod.js

Diff too large to display

Diff for app-route-ex..ntime.dev.js

Diff too large to display

Diff for app-route-ex..time.prod.js

Diff too large to display

Diff for app-route-tu..time.prod.js

Diff too large to display

Diff for app-route-tu..time.prod.js

Diff too large to display

Diff for app-route.runtime.dev.js

Diff too large to display

Diff for app-route.ru..time.prod.js

Diff too large to display

Diff for pages-turbo...time.prod.js

Diff too large to display

Diff for pages.runtime.dev.js

Diff too large to display

Diff for pages.runtime.prod.js

Diff too large to display

Diff for server.runtime.prod.js
failed to diff
Commit: 6abf5e7

@bgw bgw force-pushed the bgw/invalidation-reason-debug branch from f0a41f3 to 52089d7 Compare November 5, 2024 00:35
@bgw bgw marked this pull request as ready for review November 5, 2024 00:36
@ijjk
Copy link
Member

ijjk commented Nov 5, 2024

Tests Passed

@bgw bgw force-pushed the bgw/invalidation-reason-debug branch from 52089d7 to 6abf5e7 Compare November 5, 2024 05:24
@ijjk ijjk added the tests label Nov 5, 2024
@bgw bgw merged commit 8abe1fd into canary Nov 5, 2024
109 checks passed
@bgw bgw deleted the bgw/invalidation-reason-debug branch November 5, 2024 18:49
bgw added a commit that referenced this pull request Nov 6, 2024
bgw added a commit that referenced this pull request Nov 6, 2024
…sh invalidation reason (#72296)" (#72421)

Not sure why this is happening, but @kdy1 bisected this commit to a null pointer assertion error in napi: https://vercel.slack.com/archives/C03EWR7LGEN/p1730901839682439?thread_ts=1730899709.760659&cid=C03EWR7LGEN

Reverting until I can repro and root cause.

Closes PACK-3402
stipsan pushed a commit to sanity-io/next.js that referenced this pull request Nov 6, 2024
…idation reason (vercel#72296)

Setting the environment variable when building (`next dev`)

```
NEXT_TURBOPACK_INCLUDE_UPDATE_REASONS=1
```

causes `[Update Reasons]` messages to be logged to the terminal console (not in the browser) when a file is changed:

![Screenshot 2024-11-04 at 4.31.16 PM.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/HAZVitxRNnZz8QMiPn4a/1af5a4f0-cfba-4ca8-b188-d6be2064b0dc.png)

These messages will not appear if no reason was recorded when the invalidation happened, so this provided on a best-effort basis.

**Why?** The hope is that this can help debug cases where users get stuck in a fast refresh update loop: https://vercel.slack.com/archives/C03S8ED1DKM/p1730737898652749

Closes PACK-3374
stipsan pushed a commit to sanity-io/next.js that referenced this pull request Nov 6, 2024
…sh invalidation reason (vercel#72296)" (vercel#72421)

Not sure why this is happening, but @kdy1 bisected this commit to a null pointer assertion error in napi: https://vercel.slack.com/archives/C03EWR7LGEN/p1730901839682439?thread_ts=1730899709.760659&cid=C03EWR7LGEN

Reverting until I can repro and root cause.

Closes PACK-3402
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 20, 2024
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.

3 participants