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

[Fiber] Enable Native console.createTask Stacks When Available #29223

Merged
merged 3 commits into from
May 26, 2024

Conversation

sebmarkbage
Copy link
Collaborator

Stacked on #29206 and #29221.

This disables appending owner stacks to console when console.createTask is available in the environment. Instead we rely on native "async" stacks that end up looking like this with source maps and ignore list enabled.

Screenshot 2024-05-22 at 4 00 27 PM

Unfortunately Chrome requires a string name for each async stack and, worse, a suffix of (async) is automatically added which is very confusing since it seems like it might be an async component or something which it is not.

In this case it's not so bad because it's nice to refer to the host component which otherwise doesn't have a stack frame since it's internal. However, if there were more owners here there would also be a <Counter> (async) which ends up being kind of duplicative.

If the Chrome DevTools is not open from the start of the app, then console.createTask is disabled and so you lose the stack for those errors (or those parents if the devtools is opened later). Unlike our appended ones that are always added. That's unfortunate and likely to be a bit of a DX issue but it's also nice that it saves on perf in DEV mode for those cases. Framework dialogs can still surface the stack since we also track it in user space in parallel.

This currently doesn't track Server Components yet. We need a more clever hack for that part in a follow up.

I think I probably need to also add something to React DevTools to disable its stacks for this case too. Since it looks for stacks in the console.error and adds a stack otherwise. Since we don't add them anymore from the runtime, the DevTools adds them instead.

Copy link

vercel bot commented May 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 26, 2024 9:42pm

@react-sizebot
Copy link

react-sizebot commented May 22, 2024

Comparing: b078c81...5adda9c

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.66 kB 6.66 kB = 1.82 kB 1.82 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 496.04 kB 496.04 kB = 88.77 kB 88.77 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.67 kB 6.67 kB = 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 500.84 kB 500.84 kB = 89.46 kB 89.46 kB
facebook-www/ReactDOM-prod.classic.js = 593.48 kB 593.48 kB = 104.38 kB 104.38 kB
facebook-www/ReactDOM-prod.modern.js = 569.87 kB 569.87 kB = 100.77 kB 100.77 kB
oss-experimental/react-dom/cjs/react-dom-test-utils.development.js +15.75% 2.44 kB 2.82 kB +11.98% 1.19 kB 1.33 kB
oss-stable-semver/react-dom/cjs/react-dom-test-utils.development.js +12.84% 2.44 kB 2.75 kB +9.87% 1.19 kB 1.30 kB
oss-stable/react-dom/cjs/react-dom-test-utils.development.js +12.84% 2.44 kB 2.75 kB +9.87% 1.19 kB 1.30 kB
oss-experimental/react/cjs/react-compiler-runtime.development.js +12.61% 3.04 kB 3.43 kB +9.92% 1.45 kB 1.60 kB
oss-experimental/use-sync-external-store/cjs/use-sync-external-store.development.js +12.45% 3.09 kB 3.47 kB +9.39% 1.37 kB 1.50 kB
oss-stable-semver/react/cjs/react-compiler-runtime.development.js +10.28% 3.04 kB 3.36 kB +8.33% 1.45 kB 1.57 kB
oss-stable/react/cjs/react-compiler-runtime.development.js +10.28% 3.04 kB 3.36 kB +8.33% 1.45 kB 1.57 kB
oss-stable-semver/use-sync-external-store/cjs/use-sync-external-store.development.js +10.15% 3.09 kB 3.40 kB +7.64% 1.37 kB 1.48 kB
oss-stable/use-sync-external-store/cjs/use-sync-external-store.development.js +10.15% 3.09 kB 3.40 kB +7.64% 1.37 kB 1.48 kB
oss-experimental/use-sync-external-store/cjs/use-sync-external-store-shim.native.development.js +4.73% 8.12 kB 8.50 kB +3.92% 3.19 kB 3.32 kB
oss-experimental/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +4.41% 8.71 kB 9.09 kB +3.77% 3.29 kB 3.42 kB
oss-experimental/react-cache/cjs/react-cache.development.js +4.27% 8.99 kB 9.38 kB +4.60% 3.00 kB 3.14 kB
oss-stable-semver/use-sync-external-store/cjs/use-sync-external-store-shim.native.development.js +3.86% 8.12 kB 8.43 kB +3.29% 3.19 kB 3.30 kB
oss-stable/use-sync-external-store/cjs/use-sync-external-store-shim.native.development.js +3.86% 8.12 kB 8.43 kB +3.29% 3.19 kB 3.30 kB
oss-stable-semver/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +3.60% 8.71 kB 9.02 kB +3.22% 3.29 kB 3.40 kB
oss-stable/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +3.60% 8.71 kB 9.02 kB +3.22% 3.29 kB 3.40 kB
oss-stable-semver/react-cache/cjs/react-cache.development.js +3.48% 8.99 kB 9.31 kB +3.84% 3.00 kB 3.11 kB
oss-stable/react-cache/cjs/react-cache.development.js +3.48% 8.99 kB 9.31 kB +3.84% 3.00 kB 3.11 kB
oss-experimental/react-dom/cjs/react-dom.react-server.development.js +2.26% 17.00 kB 17.38 kB +3.64% 3.74 kB 3.88 kB
oss-experimental/react-reconciler/cjs/react-reconciler-reflection.development.js +2.01% 19.15 kB 19.53 kB +2.39% 5.48 kB 5.62 kB
test_utils/ReactAllWarnings.js Deleted 63.82 kB 0.00 kB Deleted 15.95 kB 0.00 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-experimental/react-dom/cjs/react-dom-test-utils.development.js +15.75% 2.44 kB 2.82 kB +11.98% 1.19 kB 1.33 kB
oss-stable-semver/react-dom/cjs/react-dom-test-utils.development.js +12.84% 2.44 kB 2.75 kB +9.87% 1.19 kB 1.30 kB
oss-stable/react-dom/cjs/react-dom-test-utils.development.js +12.84% 2.44 kB 2.75 kB +9.87% 1.19 kB 1.30 kB
oss-experimental/react/cjs/react-compiler-runtime.development.js +12.61% 3.04 kB 3.43 kB +9.92% 1.45 kB 1.60 kB
oss-experimental/use-sync-external-store/cjs/use-sync-external-store.development.js +12.45% 3.09 kB 3.47 kB +9.39% 1.37 kB 1.50 kB
oss-stable-semver/react/cjs/react-compiler-runtime.development.js +10.28% 3.04 kB 3.36 kB +8.33% 1.45 kB 1.57 kB
oss-stable/react/cjs/react-compiler-runtime.development.js +10.28% 3.04 kB 3.36 kB +8.33% 1.45 kB 1.57 kB
oss-stable-semver/use-sync-external-store/cjs/use-sync-external-store.development.js +10.15% 3.09 kB 3.40 kB +7.64% 1.37 kB 1.48 kB
oss-stable/use-sync-external-store/cjs/use-sync-external-store.development.js +10.15% 3.09 kB 3.40 kB +7.64% 1.37 kB 1.48 kB
oss-experimental/use-sync-external-store/cjs/use-sync-external-store-shim.native.development.js +4.73% 8.12 kB 8.50 kB +3.92% 3.19 kB 3.32 kB
oss-experimental/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +4.41% 8.71 kB 9.09 kB +3.77% 3.29 kB 3.42 kB
oss-experimental/react-cache/cjs/react-cache.development.js +4.27% 8.99 kB 9.38 kB +4.60% 3.00 kB 3.14 kB
oss-stable-semver/use-sync-external-store/cjs/use-sync-external-store-shim.native.development.js +3.86% 8.12 kB 8.43 kB +3.29% 3.19 kB 3.30 kB
oss-stable/use-sync-external-store/cjs/use-sync-external-store-shim.native.development.js +3.86% 8.12 kB 8.43 kB +3.29% 3.19 kB 3.30 kB
oss-stable-semver/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +3.60% 8.71 kB 9.02 kB +3.22% 3.29 kB 3.40 kB
oss-stable/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +3.60% 8.71 kB 9.02 kB +3.22% 3.29 kB 3.40 kB
oss-stable-semver/react-cache/cjs/react-cache.development.js +3.48% 8.99 kB 9.31 kB +3.84% 3.00 kB 3.11 kB
oss-stable/react-cache/cjs/react-cache.development.js +3.48% 8.99 kB 9.31 kB +3.84% 3.00 kB 3.11 kB
oss-experimental/react-dom/cjs/react-dom.react-server.development.js +2.26% 17.00 kB 17.38 kB +3.64% 3.74 kB 3.88 kB
oss-experimental/react-reconciler/cjs/react-reconciler-reflection.development.js +2.01% 19.15 kB 19.53 kB +2.39% 5.48 kB 5.62 kB
oss-stable-semver/react-dom/cjs/react-dom.react-server.development.js +1.84% 17.00 kB 17.31 kB +3.02% 3.74 kB 3.85 kB
oss-stable/react-dom/cjs/react-dom.react-server.development.js +1.84% 17.00 kB 17.31 kB +3.02% 3.74 kB 3.85 kB
oss-stable-semver/react-reconciler/cjs/react-reconciler-reflection.development.js +1.63% 19.15 kB 19.46 kB +1.99% 5.48 kB 5.59 kB
oss-stable/react-reconciler/cjs/react-reconciler-reflection.development.js +1.63% 19.15 kB 19.46 kB +1.99% 5.48 kB 5.59 kB
oss-experimental/react-dom/cjs/react-dom.development.js +1.55% 24.81 kB 25.20 kB +2.26% 6.37 kB 6.52 kB
oss-experimental/react/cjs/react-jsx-dev-runtime.development.js +1.47% 26.13 kB 26.52 kB +1.43% 8.47 kB 8.59 kB
oss-experimental/react/cjs/react-jsx-runtime.development.js +1.41% 27.16 kB 27.55 kB +1.38% 8.78 kB 8.90 kB
oss-experimental/react/cjs/react-jsx-runtime.react-server.development.js +1.38% 27.88 kB 28.26 kB +1.36% 8.96 kB 9.08 kB
oss-experimental/react/cjs/react-jsx-dev-runtime.react-server.development.js +1.38% 27.88 kB 28.27 kB +1.35% 8.96 kB 9.08 kB
oss-stable-semver/react-dom/cjs/react-dom.development.js +1.26% 24.78 kB 25.09 kB +1.86% 6.34 kB 6.46 kB
oss-stable/react-dom/cjs/react-dom.development.js +1.26% 24.80 kB 25.12 kB +1.82% 6.37 kB 6.49 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer.development.js +0.90% 42.89 kB 43.28 kB +1.42% 9.78 kB 9.92 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer-persistent.development.js +0.89% 43.03 kB 43.41 kB +1.40% 9.80 kB 9.94 kB
oss-stable-semver/react/cjs/react-jsx-dev-runtime.development.js +0.75% 41.49 kB 41.80 kB +0.84% 12.55 kB 12.66 kB
oss-stable/react/cjs/react-jsx-dev-runtime.development.js +0.75% 41.49 kB 41.80 kB +0.84% 12.55 kB 12.66 kB
facebook-react-native/react/cjs/JSXDEVRuntime-dev.js +0.74% 42.29 kB 42.60 kB +0.86% 12.79 kB 12.90 kB
oss-stable-semver/react/cjs/react-jsx-runtime.development.js +0.74% 42.45 kB 42.77 kB +0.81% 12.85 kB 12.95 kB
oss-stable/react/cjs/react-jsx-runtime.development.js +0.74% 42.45 kB 42.77 kB +0.81% 12.85 kB 12.95 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer.development.js +0.73% 42.89 kB 43.21 kB +1.18% 9.78 kB 9.90 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer.development.js +0.73% 42.89 kB 43.21 kB +1.18% 9.78 kB 9.90 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer-persistent.development.js +0.73% 43.03 kB 43.34 kB +1.16% 9.80 kB 9.91 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer-persistent.development.js +0.73% 43.03 kB 43.34 kB +1.16% 9.80 kB 9.91 kB
oss-stable-semver/react/cjs/react-jsx-runtime.react-server.development.js +0.73% 43.14 kB 43.45 kB +0.81% 13.02 kB 13.13 kB
oss-stable/react/cjs/react-jsx-runtime.react-server.development.js +0.73% 43.14 kB 43.45 kB +0.81% 13.02 kB 13.13 kB
oss-stable-semver/react/cjs/react-jsx-dev-runtime.react-server.development.js +0.73% 43.15 kB 43.46 kB +0.80% 13.03 kB 13.13 kB
oss-stable/react/cjs/react-jsx-dev-runtime.react-server.development.js +0.73% 43.15 kB 43.46 kB +0.80% 13.03 kB 13.13 kB
facebook-react-native/react/cjs/JSXRuntime-dev.js +0.72% 43.26 kB 43.57 kB +0.85% 13.10 kB 13.21 kB
oss-experimental/react/cjs/react.react-server.development.js +0.66% 58.01 kB 58.40 kB +0.70% 16.52 kB 16.64 kB
oss-experimental/react/cjs/react.development.js +0.49% 78.22 kB 78.60 kB +0.54% 21.51 kB 21.63 kB
oss-stable-semver/react/cjs/react.react-server.development.js +0.45% 69.19 kB 69.50 kB +0.56% 19.36 kB 19.47 kB
oss-stable/react/cjs/react.react-server.development.js +0.45% 69.21 kB 69.53 kB +0.55% 19.38 kB 19.49 kB
oss-experimental/react-client/cjs/react-client-flight.development.js +0.42% 91.92 kB 92.30 kB +0.59% 20.34 kB 20.46 kB
oss-experimental/react-server-dom-esm/esm/react-server-dom-esm-client.browser.development.js +0.42% 91.93 kB 92.31 kB +0.57% 20.06 kB 20.17 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.development.js +0.42% 92.17 kB 92.55 kB +0.57% 20.12 kB 20.24 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.browser.development.js +0.40% 95.42 kB 95.80 kB +0.59% 21.09 kB 21.21 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js +0.40% 95.93 kB 96.31 kB +0.57% 21.25 kB 21.37 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-client.node.development.js +0.38% 99.84 kB 100.23 kB +0.52% 22.13 kB 22.25 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.unbundled.development.js +0.38% 101.62 kB 102.01 kB +0.55% 22.69 kB 22.81 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js +0.38% 101.66 kB 102.04 kB +0.53% 22.71 kB 22.83 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.development.js +0.37% 103.06 kB 103.44 kB +0.52% 23.07 kB 23.19 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js +0.37% 103.09 kB 103.47 kB +0.51% 23.12 kB 23.24 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.development.js +0.37% 104.14 kB 104.52 kB +0.51% 23.28 kB 23.40 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js +0.37% 104.16 kB 104.55 kB +0.51% 23.32 kB 23.44 kB
oss-stable-semver/react-client/cjs/react-client-flight.development.js +0.34% 90.76 kB 91.08 kB +0.50% 20.15 kB 20.25 kB
oss-stable/react-client/cjs/react-client-flight.development.js +0.34% 90.76 kB 91.08 kB +0.50% 20.15 kB 20.25 kB
oss-stable-semver/react-server-dom-esm/esm/react-server-dom-esm-client.browser.development.js +0.34% 90.78 kB 91.09 kB +0.46% 19.86 kB 19.96 kB
oss-stable/react-server-dom-esm/esm/react-server-dom-esm-client.browser.development.js +0.34% 90.78 kB 91.09 kB +0.46% 19.86 kB 19.96 kB
oss-stable-semver/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.development.js +0.34% 91.02 kB 91.33 kB +0.47% 19.93 kB 20.02 kB
oss-stable/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.development.js +0.34% 91.02 kB 91.33 kB +0.47% 19.93 kB 20.02 kB
oss-stable-semver/react/cjs/react.development.js +0.33% 93.51 kB 93.82 kB +0.44% 25.62 kB 25.73 kB
oss-stable/react/cjs/react.development.js +0.33% 93.53 kB 93.84 kB +0.43% 25.65 kB 25.76 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.browser.development.js +0.33% 94.27 kB 94.58 kB +0.48% 20.89 kB 20.99 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.browser.development.js +0.33% 94.27 kB 94.58 kB +0.48% 20.89 kB 20.99 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js +0.33% 94.78 kB 95.09 kB +0.46% 21.06 kB 21.16 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js +0.33% 94.78 kB 95.09 kB +0.46% 21.06 kB 21.16 kB
oss-stable-semver/react-server-dom-esm/cjs/react-server-dom-esm-client.node.development.js +0.32% 98.69 kB 99.00 kB +0.40% 21.95 kB 22.03 kB
oss-stable/react-server-dom-esm/cjs/react-server-dom-esm-client.node.development.js +0.32% 98.69 kB 99.00 kB +0.40% 21.95 kB 22.03 kB
oss-experimental/react-server/cjs/react-server-flight.development.js +0.32% 121.84 kB 122.22 kB +0.41% 26.88 kB 26.99 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.unbundled.development.js +0.31% 100.47 kB 100.79 kB +0.43% 22.50 kB 22.59 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.unbundled.development.js +0.31% 100.47 kB 100.79 kB +0.43% 22.50 kB 22.59 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js +0.31% 100.51 kB 100.82 kB +0.42% 22.52 kB 22.62 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js +0.31% 100.51 kB 100.82 kB +0.42% 22.52 kB 22.62 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.development.js +0.31% 101.91 kB 102.22 kB +0.40% 22.89 kB 22.98 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.development.js +0.31% 101.91 kB 102.22 kB +0.40% 22.89 kB 22.98 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js +0.31% 101.93 kB 102.25 kB +0.40% 22.93 kB 23.02 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js +0.31% 101.93 kB 102.25 kB +0.40% 22.93 kB 23.02 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.development.js +0.30% 102.99 kB 103.30 kB +0.40% 23.09 kB 23.18 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.development.js +0.30% 102.99 kB 103.30 kB +0.40% 23.09 kB 23.18 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js +0.30% 103.01 kB 103.32 kB +0.39% 23.13 kB 23.22 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js +0.30% 103.01 kB 103.32 kB +0.39% 23.13 kB 23.22 kB
facebook-react-native/react/cjs/React-dev.js +0.30% 104.54 kB 104.85 kB +0.40% 28.05 kB 28.16 kB
oss-stable-semver/react-server/cjs/react-server-flight.development.js +0.29% 108.63 kB 108.94 kB +0.39% 23.94 kB 24.04 kB
oss-stable/react-server/cjs/react-server-flight.development.js +0.29% 108.63 kB 108.94 kB +0.39% 23.94 kB 24.04 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-server.node.development.js +0.22% 174.87 kB 175.25 kB +0.33% 38.54 kB 38.67 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.browser.development.js +0.21% 179.80 kB 180.18 kB +0.31% 39.51 kB 39.63 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js +0.21% 180.50 kB 180.88 kB +0.31% 39.74 kB 39.86 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.development.js +0.21% 181.72 kB 182.10 kB +0.31% 40.02 kB 40.15 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js +0.21% 181.90 kB 182.28 kB +0.30% 40.10 kB 40.22 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.unbundled.development.js +0.21% 182.74 kB 183.12 kB +0.32% 39.97 kB 40.10 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js +0.21% 182.92 kB 183.31 kB +0.32% 40.03 kB 40.16 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.development.js +0.21% 185.38 kB 185.76 kB +0.31% 40.78 kB 40.91 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js +0.21% 185.56 kB 185.94 kB +0.31% 40.86 kB 40.99 kB
test_utils/ReactAllWarnings.js Deleted 63.82 kB 0.00 kB Deleted 15.95 kB 0.00 kB

Generated by 🚫 dangerJS against 5adda9c

Copy link
Contributor

@hoxyq hoxyq left a comment

Choose a reason for hiding this comment

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

Looked at 2 commits at the top, left one question

Comment on lines +52 to +53
// Since createTask requires DevTools to be open to work, this means that stacks
// can be lost while DevTools isn't open but we can't detect this.
Copy link
Contributor

@hoxyq hoxyq May 23, 2024

Choose a reason for hiding this comment

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

Is this by design? Because I couldn't find any mention of this on web

Assuming that logs are buffered, we should expect that users will end up having different stack traces, depending on if browser DevTools are opened or not?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If the DevTools are not open, then there will only be the stack for the current callsite and not the "async stack". If that bottoms out inside React then effectively you have no stack trace.

This is not really new to console.createTask per se but even the built-in async stack traces in Chrome DevTools are only active if they DevTools is open. That's because they come with a cost even when you don't have an error. So if they were always on you'd effectively just slow down every site for every Chrome user - even if they're not a developer. Even for developers it'd slow down every page and not just the ones you're working on.

It's unfortunate for React because we don't actually bother calling console.createTask in production at all. So if everyone followed our pattern, it wouldn't slow down any sites except the "development mode" ones and you wouldn't have DevTools open.

User space dialogs would still be able to show stacks since they get our new Error().stack version.

We rely on the native stack when console.createTask is available in the runtime.
This creates a native "owner stack" for the execution context. Any JSX
created within this context will get new tasks created continuing the stack.
…ative task

If the current Fiber already has a native task, then it might be in a native async task and so we already have a component stack.

If it doesn't have a native task, it's because this is not DEV mode or it's an older React or React didn't detect console.createTask.
if (shouldAppendWarningStack) {
if (
shouldAppendWarningStack &&
!supportsNativeConsoleTasks(current)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@hoxyq I disabled the appending this way to detect if we already have a native async stack. Ideally we could detect if this was actually an "active" task somehow (i.e. the Chrome DevTools was opened at the time).

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for flagging. We could potentially look if RDT frontend is connected to RDT backend at this stage, which would mean that browser DevTools are opened for the extension case.

Would that work or do you need to know if browser DevTools are opened at the stage of task creation?

@sebmarkbage sebmarkbage merged commit ea6e059 into facebook:main May 26, 2024
40 checks passed
github-actions bot pushed a commit that referenced this pull request May 26, 2024
Stacked on #29206 and #29221.

This disables appending owner stacks to console when
`console.createTask` is available in the environment. Instead we rely on
native "async" stacks that end up looking like this with source maps and
ignore list enabled.

<img width="673" alt="Screenshot 2024-05-22 at 4 00 27 PM"
src="https://github.com/facebook/react/assets/63648/5313ed53-b298-4386-8f76-8eb85bdfbbc7">

Unfortunately Chrome requires a string name for each async stack and,
worse, a suffix of `(async)` is automatically added which is very
confusing since it seems like it might be an async component or
something which it is not.

In this case it's not so bad because it's nice to refer to the host
component which otherwise doesn't have a stack frame since it's
internal. However, if there were more owners here there would also be a
`<Counter> (async)` which ends up being kind of duplicative.

If the Chrome DevTools is not open from the start of the app, then
`console.createTask` is disabled and so you lose the stack for those
errors (or those parents if the devtools is opened later). Unlike our
appended ones that are always added. That's unfortunate and likely to be
a bit of a DX issue but it's also nice that it saves on perf in DEV mode
for those cases. Framework dialogs can still surface the stack since we
also track it in user space in parallel.

This currently doesn't track Server Components yet. We need a more
clever hack for that part in a follow up.

I think I probably need to also add something to React DevTools to
disable its stacks for this case too. Since it looks for stacks in the
console.error and adds a stack otherwise. Since we don't add them
anymore from the runtime, the DevTools adds them instead.

DiffTrain build for commit ea6e059.
github-actions bot pushed a commit that referenced this pull request May 26, 2024
Stacked on #29206 and #29221.

This disables appending owner stacks to console when
`console.createTask` is available in the environment. Instead we rely on
native "async" stacks that end up looking like this with source maps and
ignore list enabled.

<img width="673" alt="Screenshot 2024-05-22 at 4 00 27 PM"
src="https://github.com/facebook/react/assets/63648/5313ed53-b298-4386-8f76-8eb85bdfbbc7">

Unfortunately Chrome requires a string name for each async stack and,
worse, a suffix of `(async)` is automatically added which is very
confusing since it seems like it might be an async component or
something which it is not.

In this case it's not so bad because it's nice to refer to the host
component which otherwise doesn't have a stack frame since it's
internal. However, if there were more owners here there would also be a
`<Counter> (async)` which ends up being kind of duplicative.

If the Chrome DevTools is not open from the start of the app, then
`console.createTask` is disabled and so you lose the stack for those
errors (or those parents if the devtools is opened later). Unlike our
appended ones that are always added. That's unfortunate and likely to be
a bit of a DX issue but it's also nice that it saves on perf in DEV mode
for those cases. Framework dialogs can still surface the stack since we
also track it in user space in parallel.

This currently doesn't track Server Components yet. We need a more
clever hack for that part in a follow up.

I think I probably need to also add something to React DevTools to
disable its stacks for this case too. Since it looks for stacks in the
console.error and adds a stack otherwise. Since we don't add them
anymore from the runtime, the DevTools adds them instead.

DiffTrain build for [ea6e059](ea6e059)
@szuend
Copy link

szuend commented Jun 5, 2024

We (the Chrome DevTools team) are looking into ways for pages to enable async stack traces without opening DevTools. Possible avenues are 1) dedicated (new) API on the console object, 2) HTTP header, 3) meta tag.

Any preference from the react side how to enable async stacks or other ideas how to opt-in?

hoxyq added a commit that referenced this pull request Jun 18, 2024
Full list of changes:

* chore[react-devtools]: improve console arguments formatting before
passing it to original console ([hoxyq](https://github.com/hoxyq) in
[#29873](#29873))
* chore[react-devtools]: unify console patching and default to ansi
escape symbols ([hoxyq](https://github.com/hoxyq) in
[#29869](#29869))
* chore[react-devtools/backend]: remove
consoleManagedByDevToolsDuringStrictMode
([hoxyq](https://github.com/hoxyq) in
[#29856](#29856))
* chore[react-devtools/extensions]: make source maps url relative
([hoxyq](https://github.com/hoxyq) in
[#29886](#29886))
* fix[react-devtools] divided inspecting elements between inspecting do…
([vzaidman](https://github.com/vzaidman) in
[#29885](#29885))
* [Fiber] Create virtual Fiber when an error occurs during reconcilation
([sebmarkbage](https://github.com/sebmarkbage) in
[#29804](#29804))
* fix[react-devtools] component badge in light mode is now not invisible
([vzaidman](https://github.com/vzaidman) in
[#29852](#29852))
* Remove Warning: prefix and toString on console Arguments
([sebmarkbage](https://github.com/sebmarkbage) in
[#29839](#29839))
* Add jest lint rules ([rickhanlonii](https://github.com/rickhanlonii)
in [#29760](#29760))
* [Fiber] Track the Real Fiber for Key Warnings
([sebmarkbage](https://github.com/sebmarkbage) in
[#29791](#29791))
* fix[react-devtools/store-test]: fork the test to represent current be…
([hoxyq](https://github.com/hoxyq) in
[#29777](#29777))
* Default native inspections config false
([vzaidman](https://github.com/vzaidman) in
[#29784](#29784))
* fix[react-devtools] remove native inspection button when it can't be
used ([vzaidman](https://github.com/vzaidman) in
[#29779](#29779))
* chore[react-devtools]: ip => internal-ip
([hoxyq](https://github.com/hoxyq) in
[#29772](#29772))
* Fix #29724: `ip` dependency update for CVE-2024-29415
([Rekl0w](https://github.com/Rekl0w) in
[#29725](#29725))
* cleanup[react-devtools]: remove unused supportsProfiling flag from
store config ([hoxyq](https://github.com/hoxyq) in
[#29193](#29193))
* [Fiber] Enable Native console.createTask Stacks When Available
([sebmarkbage](https://github.com/sebmarkbage) in
[#29223](#29223))
* Move createElement/JSX Warnings into the Renderer
([sebmarkbage](https://github.com/sebmarkbage) in
[#29088](#29088))
* Set the current fiber to the source of the error during error
reporting ([sebmarkbage](https://github.com/sebmarkbage) in
[#29044](#29044))
* Unify ReactFiberCurrentOwner and ReactCurrentFiber
([sebmarkbage](https://github.com/sebmarkbage) in
[#29038](#29038))
* Dim `console` calls on additional Effect invocations due to
`StrictMode` ([eps1lon](https://github.com/eps1lon) in
[#29007](#29007))
* refactor[react-devtools]: rewrite context menus
([hoxyq](https://github.com/hoxyq) in
[#29049](#29049))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants