GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [Flight] Normalize Stack Using Fake Evals by sebmarkbage · Pull Request #30401 · react/react

Conversation

@sebmarkbage

@sebmarkbage sebmarkbage commented Jul 19, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Stacked on #30400 and #30369

Previously we were using fake evals to recreate a stack for console replaying and thrown errors. However, for owner stacks we just used the raw string that came from the server.

This means that the format of the owner stack could include different formats. Like Spidermonkey format for the client components and V8 for the server components. This means that this stack can't be parsed natively by the browser like when printing them as error like in #30289. Additionally, since there's no source file registered with that name and no source mapping url, it can't be source mapped.

Before:

before-firefox

Instead, we need to create a fake stack like we do for the other things. That way when it's printed as an Error it gets source mapped. It also means that the format is consistently in the native format of the current browser.

After:

after-firefox

So this is nice because you can just take the result from captureOwnerStack() and append it to an Error stack and print it natively. E.g. this is what React DevTools will do.

If you want to parse and present it yourself though it's a bit awkward though. The captureOwnerStack() API now includes a bunch of rsc://React/ URLs. These don't really have any direct connection to the source map. Only the browser knows this connection from the eval. You basically have to strip the prefix and then manually pass the remainder to your own findSourceMapURL.

Another awkward part is that since Safari doesn't support eval sourceURL exposed into error.stack - it means that captureOwnerStack() get an empty location for server components since the fake eval doesn't work there. That's not a big deal since these stacks are already broken even for client modules for many because the eval-source-map strategy in Webpack doesn't work in Safari for this same reason.

A lot of this refactoring is just clarifying that there's three kind of ReactComponentInfo fields:

  • stack - The raw stack as described on the original server.
  • debugStack - The Error object containing the stack as represented in the current client as fake evals.
  • debugTask - The same thing as debugStack but described in terms of a native console.createTask.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sebmarkbage
sebmarkbage requested review from eps1lon and gnoff July 19, 2024 03:34
@vercel

vercel Bot commented Jul 19, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

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 Jul 22, 2024 2:59pm
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Jul 19, 2024
@vercel
vercel Bot deployed to Preview July 19, 2024 03:37
View deployment
@react-sizebot

react-sizebot commented Jul 19, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Comparing: 792f1921145e51bd06b836ffa0a16ecc39c8ee82...25af7106d416992adf04b477c414400febd53a80

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.68 kB 6.68 kB = 1.82 kB 1.82 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 499.44 kB 499.44 kB = 89.59 kB 89.59 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB = 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 504.26 kB 504.26 kB = 90.30 kB 90.30 kB
facebook-www/ReactDOM-prod.classic.js = 599.20 kB 599.20 kB = 105.79 kB 105.79 kB
facebook-www/ReactDOM-prod.modern.js = 573.37 kB 573.37 kB = 101.68 kB 101.68 kB
oss-stable-rc/react-server-dom-esm/esm/react-server-dom-esm-client.browser.development.js +5.14% 98.52 kB 103.59 kB +7.91% 21.63 kB 23.34 kB
oss-stable-semver/react-server-dom-esm/esm/react-server-dom-esm-client.browser.development.js +5.14% 98.52 kB 103.59 kB +7.91% 21.63 kB 23.34 kB
oss-stable/react-server-dom-esm/esm/react-server-dom-esm-client.browser.development.js +5.14% 98.52 kB 103.59 kB +7.91% 21.63 kB 23.34 kB
oss-stable-rc/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.development.js +4.32% 69.69 kB 72.70 kB +6.45% 12.89 kB 13.72 kB
oss-stable-semver/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.development.js +4.32% 69.69 kB 72.70 kB +6.45% 12.89 kB 13.72 kB
oss-stable/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.development.js +4.32% 69.69 kB 72.70 kB +6.45% 12.89 kB 13.72 kB
oss-stable-rc/react-client/cjs/react-client-flight.development.js +4.24% 73.27 kB 76.38 kB +6.21% 13.25 kB 14.07 kB
oss-stable-semver/react-client/cjs/react-client-flight.development.js +4.24% 73.27 kB 76.38 kB +6.21% 13.25 kB 14.07 kB
oss-stable/react-client/cjs/react-client-flight.development.js +4.24% 73.27 kB 76.38 kB +6.21% 13.25 kB 14.07 kB
oss-stable-rc/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.browser.development.js +4.21% 71.54 kB 74.55 kB +6.42% 13.26 kB 14.11 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.browser.development.js +4.21% 71.54 kB 74.55 kB +6.42% 13.26 kB 14.11 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.browser.development.js +4.21% 71.54 kB 74.55 kB +6.42% 13.26 kB 14.11 kB
oss-stable-rc/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js +4.18% 71.99 kB 75.00 kB +6.24% 13.41 kB 14.24 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js +4.18% 71.99 kB 75.00 kB +6.24% 13.41 kB 14.24 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js +4.18% 71.99 kB 75.00 kB +6.24% 13.41 kB 14.24 kB
oss-stable-rc/react-server-dom-esm/cjs/react-server-dom-esm-client.node.development.js +4.17% 74.63 kB 77.74 kB +5.78% 13.97 kB 14.78 kB
oss-stable-semver/react-server-dom-esm/cjs/react-server-dom-esm-client.node.development.js +4.17% 74.63 kB 77.74 kB +5.78% 13.97 kB 14.78 kB
oss-stable/react-server-dom-esm/cjs/react-server-dom-esm-client.node.development.js +4.17% 74.63 kB 77.74 kB +5.78% 13.97 kB 14.78 kB
oss-stable-rc/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.unbundled.development.js +4.09% 76.04 kB 79.15 kB +5.66% 14.28 kB 15.08 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.unbundled.development.js +4.09% 76.04 kB 79.15 kB +5.66% 14.28 kB 15.08 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.unbundled.development.js +4.09% 76.04 kB 79.15 kB +5.66% 14.28 kB 15.08 kB
oss-stable-rc/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.development.js +4.05% 76.84 kB 79.95 kB +5.60% 14.45 kB 15.26 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.development.js +4.05% 76.84 kB 79.95 kB +5.60% 14.45 kB 15.26 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.development.js +4.05% 76.84 kB 79.95 kB +5.60% 14.45 kB 15.26 kB
oss-stable-rc/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js +3.98% 78.20 kB 81.31 kB +5.71% 14.69 kB 15.53 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js +3.98% 78.20 kB 81.31 kB +5.71% 14.69 kB 15.53 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js +3.98% 78.20 kB 81.31 kB +5.71% 14.69 kB 15.53 kB
oss-stable-rc/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.development.js +3.97% 78.22 kB 81.33 kB +5.71% 14.67 kB 15.51 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.development.js +3.97% 78.22 kB 81.33 kB +5.71% 14.67 kB 15.51 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.development.js +3.97% 78.22 kB 81.33 kB +5.71% 14.67 kB 15.51 kB
oss-stable-rc/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js +3.89% 79.92 kB 83.03 kB +5.45% 14.79 kB 15.60 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js +3.89% 79.92 kB 83.03 kB +5.45% 14.79 kB 15.60 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js +3.89% 79.92 kB 83.03 kB +5.45% 14.79 kB 15.60 kB
oss-stable-rc/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js +3.85% 80.71 kB 83.81 kB +5.41% 14.97 kB 15.78 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js +3.85% 80.71 kB 83.81 kB +5.41% 14.97 kB 15.78 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js +3.85% 80.71 kB 83.81 kB +5.41% 14.97 kB 15.78 kB
oss-experimental/react-server-dom-esm/esm/react-server-dom-esm-client.browser.development.js +2.01% 107.95 kB 110.12 kB +2.30% 24.25 kB 24.81 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable-rc/react-server-dom-esm/esm/react-server-dom-esm-client.browser.development.js +5.14% 98.52 kB 103.59 kB +7.91% 21.63 kB 23.34 kB
oss-stable-semver/react-server-dom-esm/esm/react-server-dom-esm-client.browser.development.js +5.14% 98.52 kB 103.59 kB +7.91% 21.63 kB 23.34 kB
oss-stable/react-server-dom-esm/esm/react-server-dom-esm-client.browser.development.js +5.14% 98.52 kB 103.59 kB +7.91% 21.63 kB 23.34 kB
oss-stable-rc/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.development.js +4.32% 69.69 kB 72.70 kB +6.45% 12.89 kB 13.72 kB
oss-stable-semver/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.development.js +4.32% 69.69 kB 72.70 kB +6.45% 12.89 kB 13.72 kB
oss-stable/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.development.js +4.32% 69.69 kB 72.70 kB +6.45% 12.89 kB 13.72 kB
oss-stable-rc/react-client/cjs/react-client-flight.development.js +4.24% 73.27 kB 76.38 kB +6.21% 13.25 kB 14.07 kB
oss-stable-semver/react-client/cjs/react-client-flight.development.js +4.24% 73.27 kB 76.38 kB +6.21% 13.25 kB 14.07 kB
oss-stable/react-client/cjs/react-client-flight.development.js +4.24% 73.27 kB 76.38 kB +6.21% 13.25 kB 14.07 kB
oss-stable-rc/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.browser.development.js +4.21% 71.54 kB 74.55 kB +6.42% 13.26 kB 14.11 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.browser.development.js +4.21% 71.54 kB 74.55 kB +6.42% 13.26 kB 14.11 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.browser.development.js +4.21% 71.54 kB 74.55 kB +6.42% 13.26 kB 14.11 kB
oss-stable-rc/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js +4.18% 71.99 kB 75.00 kB +6.24% 13.41 kB 14.24 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js +4.18% 71.99 kB 75.00 kB +6.24% 13.41 kB 14.24 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js +4.18% 71.99 kB 75.00 kB +6.24% 13.41 kB 14.24 kB
oss-stable-rc/react-server-dom-esm/cjs/react-server-dom-esm-client.node.development.js +4.17% 74.63 kB 77.74 kB +5.78% 13.97 kB 14.78 kB
oss-stable-semver/react-server-dom-esm/cjs/react-server-dom-esm-client.node.development.js +4.17% 74.63 kB 77.74 kB +5.78% 13.97 kB 14.78 kB
oss-stable/react-server-dom-esm/cjs/react-server-dom-esm-client.node.development.js +4.17% 74.63 kB 77.74 kB +5.78% 13.97 kB 14.78 kB
oss-stable-rc/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.unbundled.development.js +4.09% 76.04 kB 79.15 kB +5.66% 14.28 kB 15.08 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.unbundled.development.js +4.09% 76.04 kB 79.15 kB +5.66% 14.28 kB 15.08 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.unbundled.development.js +4.09% 76.04 kB 79.15 kB +5.66% 14.28 kB 15.08 kB
oss-stable-rc/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.development.js +4.05% 76.84 kB 79.95 kB +5.60% 14.45 kB 15.26 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.development.js +4.05% 76.84 kB 79.95 kB +5.60% 14.45 kB 15.26 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.development.js +4.05% 76.84 kB 79.95 kB +5.60% 14.45 kB 15.26 kB
oss-stable-rc/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js +3.98% 78.20 kB 81.31 kB +5.71% 14.69 kB 15.53 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js +3.98% 78.20 kB 81.31 kB +5.71% 14.69 kB 15.53 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js +3.98% 78.20 kB 81.31 kB +5.71% 14.69 kB 15.53 kB
oss-stable-rc/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.development.js +3.97% 78.22 kB 81.33 kB +5.71% 14.67 kB 15.51 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.development.js +3.97% 78.22 kB 81.33 kB +5.71% 14.67 kB 15.51 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.development.js +3.97% 78.22 kB 81.33 kB +5.71% 14.67 kB 15.51 kB
oss-stable-rc/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js +3.89% 79.92 kB 83.03 kB +5.45% 14.79 kB 15.60 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js +3.89% 79.92 kB 83.03 kB +5.45% 14.79 kB 15.60 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js +3.89% 79.92 kB 83.03 kB +5.45% 14.79 kB 15.60 kB
oss-stable-rc/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js +3.85% 80.71 kB 83.81 kB +5.41% 14.97 kB 15.78 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js +3.85% 80.71 kB 83.81 kB +5.41% 14.97 kB 15.78 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js +3.85% 80.71 kB 83.81 kB +5.41% 14.97 kB 15.78 kB
oss-experimental/react-server-dom-esm/esm/react-server-dom-esm-client.browser.development.js +2.01% 107.95 kB 110.12 kB +2.30% 24.25 kB 24.81 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js +1.47% 78.11 kB 79.26 kB +1.21% 14.91 kB 15.09 kB
oss-experimental/react-client/cjs/react-client-flight.development.js +1.44% 79.55 kB 80.70 kB +1.25% 14.68 kB 14.86 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.development.js +1.43% 75.82 kB 76.90 kB +1.26% 14.38 kB 14.56 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-client.node.development.js +1.42% 80.75 kB 81.90 kB +1.20% 15.40 kB 15.58 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.browser.development.js +1.40% 77.66 kB 78.75 kB +1.21% 14.79 kB 14.97 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.unbundled.development.js +1.40% 82.16 kB 83.31 kB +1.18% 15.72 kB 15.91 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.development.js +1.38% 82.96 kB 84.11 kB +1.17% 15.89 kB 16.08 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js +1.36% 84.33 kB 85.47 kB +1.16% 16.18 kB 16.37 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.development.js +1.36% 84.34 kB 85.49 kB +1.14% 16.16 kB 16.35 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js +1.33% 86.08 kB 87.22 kB +1.14% 16.25 kB 16.43 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js +1.32% 86.86 kB 88.01 kB +1.13% 16.43 kB 16.62 kB
oss-experimental/react-server/cjs/react-server-flight.development.js +1.25% 94.09 kB 95.27 kB +0.89% 17.47 kB 17.62 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-server.node.development.js +0.87% 134.57 kB 135.75 kB +0.65% 25.09 kB 25.25 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.browser.development.js +0.85% 137.79 kB 138.96 kB +0.60% 25.64 kB 25.80 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js +0.85% 138.41 kB 139.58 kB +0.59% 25.82 kB 25.97 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.development.js +0.84% 139.85 kB 141.03 kB +0.62% 25.96 kB 26.12 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js +0.84% 140.00 kB 141.18 kB +0.61% 26.02 kB 26.18 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.unbundled.development.js +0.83% 140.94 kB 142.11 kB +0.59% 26.07 kB 26.23 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js +0.83% 141.10 kB 142.28 kB +0.59% 26.14 kB 26.29 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.development.js +0.83% 142.05 kB 143.22 kB +0.58% 26.34 kB 26.49 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js +0.83% 142.19 kB 143.37 kB +0.57% 26.40 kB 26.55 kB
oss-experimental/react-html/cjs/react-html.react-server.development.js +0.52% 482.39 kB 484.89 kB +0.48% 87.32 kB 87.74 kB

Generated by 🚫 dangerJS against 523ef76

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sebmarkbage
sebmarkbage requested a review from hoxyq July 19, 2024 03:41
sebmarkbage
sebmarkbage commented Jul 19, 2024
View reviewed changes
Comment thread packages/react-server/src/ReactFlightOwnerStack.js
@@ -0,0 +1,42 @@
/**

@sebmarkbage sebmarkbage Jul 19, 2024

Copy link
Copy Markdown
Contributor Author

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.

I think it's likely that Fiber/Fizz/Flight OwnerStack.js merge into a shared helper for extracting a presentable string.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
sebmarkbage
sebmarkbage commented Jul 19, 2024
View reviewed changes
Comment thread packages/react-server/src/ReactFlightServer.js
return stack.slice(startIdx, endIdx);
}

function filterDebugStack(error: Error): string {

@sebmarkbage sebmarkbage Jul 19, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

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 different from the one in FlightOwnerStack which is for formatting the string for captureOwnerStack() for presentation.

This one is for formatting the string into the serializable stack field for serialization. This is turning into a structured form instead of a string in the follow up #30410.

This could be coming from the current server, however, this Error could also be one that includes fake stack frames it originated on another server. In this case we'd need to do something to reverse engineer it to get it back into its serialized form. E.g. stripping the rsc://React/ prefixes.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
sebmarkbage
sebmarkbage commented Jul 20, 2024
View reviewed changes
Comment thread packages/react-client/src/ReactFlightClient.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@sebmarkbage
sebmarkbage force-pushed the flightnormalizestack branch from a83d050 to 1794201 Compare July 20, 2024 01:51
@vercel
vercel Bot deployed to Preview July 20, 2024 01:53
View deployment
@sebmarkbage sebmarkbage mentioned this pull request Jul 20, 2024
[Flight] Parse Stack on the Server and Transfer Structured Stack #30410
Merged
@sebmarkbage

sebmarkbage commented Jul 20, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There's three "urls/files" essentially:

  • The original source file. We get this from the source map.
  • The file that was loaded by the server. This could be the compiled output of Babel or even bundled which might represent a "chunk". In our fixture this has the same url as the original source file since it's not bundled but it doesn't have the same line/column numbers since it is transpiled.
  • The fake eval file that was generated by the Flight Client. This is file/chunk loaded by the server prefixed by rsc://React/.

While it would be enough for us to emit the original source file URL + original line number + column number in the stack to get it pointing to the right place, we don't actually have this information in React.

It is also not enough to point to the url loaded by the server, because the browser doesn't have access to this. E.g. if it's a bundled chunk that is never loaded by the browser. The browser only sees the fake eval and the source map pointing to the original source file. Even if it's not bundled and just transpiled we'd have the file but we'd not have the original line number.

We also need to generate more than one fake eval per file so we give it the + "?" + id suffix. We could just use this suffix to differentiate and then that might make it easier to parse the owner stack. You'd get an extra suffix but the right file path. The problem with that is that the way they're presented in the file view in browsers is next to each other which makes that view kind of useless. So the tradeoff is to make parsing owner stacks manually a bit more difficult by needing to remove the RSC specific prefix.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

eps1lon
eps1lon approved these changes Jul 22, 2024
View reviewed changes
sebmarkbage added 3 commits July 22, 2024 10:49
@sebmarkbage
Build a normalized native stack trace using fake evals
c062eb0
We already do this for recreating serialized errors.

This does it for stacks both in the stacks of parent components,
JSX callsites and owners.
@sebmarkbage
Rename task on ReactComponentInfo to debugTask
8d29f53
This represents the stack trace as a native console.createTask object in
the current execution environment. Not as part of the serialized protocol.
@sebmarkbage
Save native stack as a separate Error
523ef76
This represents the stack in the current execution environment. As opposed
to the .stack property which represents the stack in the transport protocol.
@sebmarkbage
sebmarkbage force-pushed the flightnormalizestack branch from 1794201 to 523ef76 Compare July 22, 2024 14:57
@vercel
vercel Bot deployed to Preview July 22, 2024 14:59
View deployment
@sebmarkbage
sebmarkbage merged commit b15c198 into react:main Jul 22, 2024
github-actions Bot pushed a commit that referenced this pull request Jul 22, 2024
@sebmarkbage
[Flight] Normalize Stack Using Fake Evals (#30401)
48b7a7e
Stacked on #30400 and
#30369

Previously we were using fake evals to recreate a stack for console
replaying and thrown errors. However, for owner stacks we just used the
raw string that came from the server.

This means that the format of the owner stack could include different
formats. Like Spidermonkey format for the client components and V8 for
the server components. This means that this stack can't be parsed
natively by the browser like when printing them as error like in
#30289. Additionally, since
there's no source file registered with that name and no source mapping
url, it can't be source mapped.

Before:

<img width="1329" alt="before-firefox"
src="https://github.com/user-attachments/assets/cbe03f9c-96ac-48fb-b58f-f3a224a774f4">

Instead, we need to create a fake stack like we do for the other things.
That way when it's printed as an Error it gets source mapped. It also
means that the format is consistently in the native format of the
current browser.

After:

<img width="753" alt="after-firefox"
src="https://github.com/user-attachments/assets/b436f1f5-ca37-4203-b29f-df9828c9fad3">

So this is nice because you can just take the result from
`captureOwnerStack()` and append it to an `Error` stack and print it
natively. E.g. this is what React DevTools will do.

If you want to parse and present it yourself though it's a bit awkward
though. The `captureOwnerStack()` API now includes a bunch of
`rsc://React/` URLs. These don't really have any direct connection to
the source map. Only the browser knows this connection from the eval.
You basically have to strip the prefix and then manually pass the
remainder to your own `findSourceMapURL`.

Another awkward part is that since Safari doesn't support eval sourceURL
exposed into `error.stack` - it means that `captureOwnerStack()` get an
empty location for server components since the fake eval doesn't work
there. That's not a big deal since these stacks are already broken even
for client modules for many because the `eval-source-map` strategy in
Webpack doesn't work in Safari for this same reason.

A lot of this refactoring is just clarifying that there's three kind of
ReactComponentInfo fields:

- `stack` - The raw stack as described on the original server.
- `debugStack` - The Error object containing the stack as represented in
the current client as fake evals.
- `debugTask` - The same thing as `debugStack` but described in terms of
a native `console.createTask`.

DiffTrain build for [b15c198](b15c198)
sebmarkbage added a commit that referenced this pull request Jul 22, 2024
@sebmarkbage
[Flight] Parse Stack on the Server and Transfer Structured Stack (#30410
0676385
)

Stacked on #30401.

Previously we were transferring the original V8 stack trace string to
the client and then parsing it there. However, really the server is the
one that knows what format it is and it should be able to vary by server
environment.

We also don't use the raw string anymore (at least not in
enableOwnerStacks). We always create the native Error stacks.

The string also made it unclear which environment it is and it was
tempting to just use it as is.

Instead I parse it on the server and make it a structured stack in the
transfer format. It also makes it clear that it needs to be formatted in
the current environment before presented.
@eps1lon eps1lon mentioned this pull request Jul 23, 2024
Update React from 01172397-20240716 to f6cce072-20240723 vercel/next.js#68075
Closed
felixshiftellecon added a commit to felixshiftellecon/react that referenced this pull request Jul 24, 2024
@felixshiftellecon
[Flight] Parse Stack on the Server and Transfer Structured Stack (rea…
0a0be8d
…ct#30410)

Stacked on react#30401.

Previously we were transferring the original V8 stack trace string to
the client and then parsing it there. However, really the server is the
one that knows what format it is and it should be able to vary by server
environment.

We also don't use the raw string anymore (at least not in
enableOwnerStacks). We always create the native Error stacks.

The string also made it unclear which environment it is and it was
tempting to just use it as is.

Instead I parse it on the server and make it a structured stack in the
transfer format. It also makes it clear that it needs to be formatted in
the current environment before presented.
felixshiftellecon added a commit to felixshiftellecon/react that referenced this pull request Jul 24, 2024
@felixshiftellecon
[Flight] Normalize Stack Using Fake Evals (react#30401)
e752921
Stacked on react#30400 and
react#30369

Previously we were using fake evals to recreate a stack for console
replaying and thrown errors. However, for owner stacks we just used the
raw string that came from the server.

This means that the format of the owner stack could include different
formats. Like Spidermonkey format for the client components and V8 for
the server components. This means that this stack can't be parsed
natively by the browser like when printing them as error like in
react#30289. Additionally, since
there's no source file registered with that name and no source mapping
url, it can't be source mapped.

Before:

<img width="1329" alt="before-firefox"
src="https://github.com/user-attachments/assets/cbe03f9c-96ac-48fb-b58f-f3a224a774f4">

Instead, we need to create a fake stack like we do for the other things.
That way when it's printed as an Error it gets source mapped. It also
means that the format is consistently in the native format of the
current browser.

After:

<img width="753" alt="after-firefox"
src="https://github.com/user-attachments/assets/b436f1f5-ca37-4203-b29f-df9828c9fad3">

So this is nice because you can just take the result from
`captureOwnerStack()` and append it to an `Error` stack and print it
natively. E.g. this is what React DevTools will do.

If you want to parse and present it yourself though it's a bit awkward
though. The `captureOwnerStack()` API now includes a bunch of
`rsc://React/` URLs. These don't really have any direct connection to
the source map. Only the browser knows this connection from the eval.
You basically have to strip the prefix and then manually pass the
remainder to your own `findSourceMapURL`.

Another awkward part is that since Safari doesn't support eval sourceURL
exposed into `error.stack` - it means that `captureOwnerStack()` get an
empty location for server components since the fake eval doesn't work
there. That's not a big deal since these stacks are already broken even
for client modules for many because the `eval-source-map` strategy in
Webpack doesn't work in Safari for this same reason.

A lot of this refactoring is just clarifying that there's three kind of
ReactComponentInfo fields:

- `stack` - The raw stack as described on the original server.
- `debugStack` - The Error object containing the stack as represented in
the current client as fake evals.
- `debugTask` - The same thing as `debugStack` but described in terms of
a native `console.createTask`.
felixshiftellecon added a commit to felixshiftellecon/react that referenced this pull request Jul 24, 2024
@felixshiftellecon
[Flight] Parse Stack on the Server and Transfer Structured Stack (rea…
ad44805
…ct#30410)

Stacked on react#30401.

Previously we were transferring the original V8 stack trace string to
the client and then parsing it there. However, really the server is the
one that knows what format it is and it should be able to vary by server
environment.

We also don't use the raw string anymore (at least not in
enableOwnerStacks). We always create the native Error stacks.

The string also made it unclear which environment it is and it was
tempting to just use it as is.

Instead I parse it on the server and make it a structured stack in the
transfer format. It also makes it clear that it needs to be formatted in
the current environment before presented.
felixshiftellecon added a commit to felixshiftellecon/react that referenced this pull request Jul 24, 2024
@felixshiftellecon
[Flight] Normalize Stack Using Fake Evals (react#30401)
b592b98
Stacked on react#30400 and
react#30369

Previously we were using fake evals to recreate a stack for console
replaying and thrown errors. However, for owner stacks we just used the
raw string that came from the server.

This means that the format of the owner stack could include different
formats. Like Spidermonkey format for the client components and V8 for
the server components. This means that this stack can't be parsed
natively by the browser like when printing them as error like in
react#30289. Additionally, since
there's no source file registered with that name and no source mapping
url, it can't be source mapped.

Before:

<img width="1329" alt="before-firefox"
src="https://github.com/user-attachments/assets/cbe03f9c-96ac-48fb-b58f-f3a224a774f4">

Instead, we need to create a fake stack like we do for the other things.
That way when it's printed as an Error it gets source mapped. It also
means that the format is consistently in the native format of the
current browser.

After:

<img width="753" alt="after-firefox"
src="https://github.com/user-attachments/assets/b436f1f5-ca37-4203-b29f-df9828c9fad3">

So this is nice because you can just take the result from
`captureOwnerStack()` and append it to an `Error` stack and print it
natively. E.g. this is what React DevTools will do.

If you want to parse and present it yourself though it's a bit awkward
though. The `captureOwnerStack()` API now includes a bunch of
`rsc://React/` URLs. These don't really have any direct connection to
the source map. Only the browser knows this connection from the eval.
You basically have to strip the prefix and then manually pass the
remainder to your own `findSourceMapURL`.

Another awkward part is that since Safari doesn't support eval sourceURL
exposed into `error.stack` - it means that `captureOwnerStack()` get an
empty location for server components since the fake eval doesn't work
there. That's not a big deal since these stacks are already broken even
for client modules for many because the `eval-source-map` strategy in
Webpack doesn't work in Safari for this same reason.

A lot of this refactoring is just clarifying that there's three kind of
ReactComponentInfo fields:

- `stack` - The raw stack as described on the original server.
- `debugStack` - The Error object containing the stack as represented in
the current client as fake evals.
- `debugTask` - The same thing as `debugStack` but described in terms of
a native `console.createTask`.
@eps1lon eps1lon mentioned this pull request Jul 25, 2024
Update React from 6230622a1a-20240610 to 76002254-20240724 vercel/next.js#68149
Merged
@eps1lon eps1lon mentioned this pull request Jul 30, 2024
Update React from 6230622a1a-20240610 to 3208e73e-20240730 vercel/next.js#68330
Merged
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
@sebmarkbage
[Flight] Normalize Stack Using Fake Evals (react#30401)
e8e8ea4
Stacked on react#30400 and
react#30369

Previously we were using fake evals to recreate a stack for console
replaying and thrown errors. However, for owner stacks we just used the
raw string that came from the server.

This means that the format of the owner stack could include different
formats. Like Spidermonkey format for the client components and V8 for
the server components. This means that this stack can't be parsed
natively by the browser like when printing them as error like in
react#30289. Additionally, since
there's no source file registered with that name and no source mapping
url, it can't be source mapped.

Before:

<img width="1329" alt="before-firefox"
src="https://github.com/user-attachments/assets/cbe03f9c-96ac-48fb-b58f-f3a224a774f4">

Instead, we need to create a fake stack like we do for the other things.
That way when it's printed as an Error it gets source mapped. It also
means that the format is consistently in the native format of the
current browser.

After:

<img width="753" alt="after-firefox"
src="https://github.com/user-attachments/assets/b436f1f5-ca37-4203-b29f-df9828c9fad3">

So this is nice because you can just take the result from
`captureOwnerStack()` and append it to an `Error` stack and print it
natively. E.g. this is what React DevTools will do.

If you want to parse and present it yourself though it's a bit awkward
though. The `captureOwnerStack()` API now includes a bunch of
`rsc://React/` URLs. These don't really have any direct connection to
the source map. Only the browser knows this connection from the eval.
You basically have to strip the prefix and then manually pass the
remainder to your own `findSourceMapURL`.

Another awkward part is that since Safari doesn't support eval sourceURL
exposed into `error.stack` - it means that `captureOwnerStack()` get an
empty location for server components since the fake eval doesn't work
there. That's not a big deal since these stacks are already broken even
for client modules for many because the `eval-source-map` strategy in
Webpack doesn't work in Safari for this same reason.

A lot of this refactoring is just clarifying that there's three kind of
ReactComponentInfo fields:

- `stack` - The raw stack as described on the original server.
- `debugStack` - The Error object containing the stack as represented in
the current client as fake evals.
- `debugTask` - The same thing as `debugStack` but described in terms of
a native `console.createTask`.
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
@sebmarkbage
[Flight] Parse Stack on the Server and Transfer Structured Stack (rea…
46785d5
…ct#30410)

Stacked on react#30401.

Previously we were transferring the original V8 stack trace string to
the client and then parsing it there. However, really the server is the
one that knows what format it is and it should be able to vary by server
environment.

We also don't use the raw string anymore (at least not in
enableOwnerStacks). We always create the native Error stacks.

The string also made it unclear which environment it is and it was
tempting to just use it as is.

Instead I parse it on the server and make it a structured stack in the
transfer format. It also makes it clear that it needs to be formatted in
the current environment before presented.

This branch was successfully deployed

1 active deployment
Preview — 523ef76d Deployed Jul 22, 2024 by vercel[bot]
View deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@eps1lon eps1lon eps1lon approved these changes
@gnoff gnoff Awaiting requested review from gnoff
@hoxyq hoxyq Awaiting requested review from hoxyq

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@sebmarkbage @react-sizebot @eps1lon @facebook-github-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.