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

[Flight] Parse Stack on the Server and Transfer Structured Stack #30410

Merged
merged 2 commits into from
Jul 22, 2024

Conversation

sebmarkbage
Copy link
Collaborator

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.

@sebmarkbage sebmarkbage requested a review from eps1lon July 20, 2024 05:22
Copy link

vercel bot commented Jul 20, 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 Jul 22, 2024 3:13pm

@react-sizebot
Copy link

react-sizebot commented Jul 20, 2024

Comparing: b15c198...fe22766

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.83 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.31 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

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/cjs/react-server-flight.development.js +1.71% 81.01 kB 82.39 kB +2.85% 15.05 kB 15.48 kB
oss-stable-semver/react-server/cjs/react-server-flight.development.js +1.71% 81.01 kB 82.39 kB +2.85% 15.05 kB 15.48 kB
oss-stable/react-server/cjs/react-server-flight.development.js +1.71% 81.01 kB 82.39 kB +2.85% 15.05 kB 15.48 kB
oss-stable-rc/react-server-dom-esm/cjs/react-server-dom-esm-server.node.development.js +1.14% 121.00 kB 122.39 kB +1.92% 22.58 kB 23.01 kB
oss-stable-semver/react-server-dom-esm/cjs/react-server-dom-esm-server.node.development.js +1.14% 121.00 kB 122.39 kB +1.92% 22.58 kB 23.01 kB
oss-stable/react-server-dom-esm/cjs/react-server-dom-esm-server.node.development.js +1.14% 121.00 kB 122.39 kB +1.92% 22.58 kB 23.01 kB
oss-stable-rc/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.browser.development.js +1.11% 124.74 kB 126.13 kB +1.86% 23.17 kB 23.60 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.browser.development.js +1.11% 124.74 kB 126.13 kB +1.86% 23.17 kB 23.60 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.browser.development.js +1.11% 124.74 kB 126.13 kB +1.86% 23.17 kB 23.60 kB
oss-stable-rc/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js +1.10% 125.37 kB 126.75 kB +1.84% 23.36 kB 23.79 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js +1.10% 125.37 kB 126.75 kB +1.84% 23.36 kB 23.79 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js +1.10% 125.37 kB 126.75 kB +1.84% 23.36 kB 23.79 kB
oss-stable-rc/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.development.js +1.10% 125.92 kB 127.30 kB +1.85% 23.37 kB 23.81 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.development.js +1.10% 125.92 kB 127.30 kB +1.85% 23.37 kB 23.81 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.development.js +1.10% 125.92 kB 127.30 kB +1.85% 23.37 kB 23.81 kB
oss-stable-rc/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js +1.10% 126.07 kB 127.45 kB +1.85% 23.44 kB 23.88 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js +1.10% 126.07 kB 127.45 kB +1.85% 23.44 kB 23.88 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js +1.10% 126.07 kB 127.45 kB +1.85% 23.44 kB 23.88 kB
oss-stable-rc/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.unbundled.development.js +1.09% 127.37 kB 128.75 kB +1.83% 23.54 kB 23.97 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.unbundled.development.js +1.09% 127.37 kB 128.75 kB +1.83% 23.54 kB 23.97 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.unbundled.development.js +1.09% 127.37 kB 128.75 kB +1.83% 23.54 kB 23.97 kB
oss-stable-rc/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js +1.08% 127.53 kB 128.91 kB +1.83% 23.60 kB 24.03 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js +1.08% 127.53 kB 128.91 kB +1.83% 23.60 kB 24.03 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js +1.08% 127.53 kB 128.91 kB +1.83% 23.60 kB 24.03 kB
oss-stable-rc/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.development.js +1.08% 128.48 kB 129.86 kB +1.80% 23.81 kB 24.24 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.development.js +1.08% 128.48 kB 129.86 kB +1.80% 23.81 kB 24.24 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.development.js +1.08% 128.48 kB 129.86 kB +1.80% 23.81 kB 24.24 kB
oss-stable-rc/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js +1.08% 128.62 kB 130.01 kB +1.80% 23.88 kB 24.31 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js +1.08% 128.62 kB 130.01 kB +1.80% 23.88 kB 24.31 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js +1.08% 128.62 kB 130.01 kB +1.80% 23.88 kB 24.31 kB
oss-experimental/react-server/cjs/react-server-flight.development.js +0.79% 95.27 kB 96.02 kB +1.25% 17.62 kB 17.84 kB
oss-stable-rc/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.development.js +0.71% 72.70 kB 73.22 kB +0.40% 13.72 kB 13.78 kB
oss-stable-semver/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.development.js +0.71% 72.70 kB 73.22 kB +0.40% 13.72 kB 13.78 kB
oss-stable/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.development.js +0.71% 72.70 kB 73.22 kB +0.40% 13.72 kB 13.78 kB
oss-stable-rc/react-client/cjs/react-client-flight.development.js +0.70% 76.38 kB 76.91 kB +0.39% 14.07 kB 14.13 kB
oss-stable-semver/react-client/cjs/react-client-flight.development.js +0.70% 76.38 kB 76.91 kB +0.39% 14.07 kB 14.13 kB
oss-stable/react-client/cjs/react-client-flight.development.js +0.70% 76.38 kB 76.91 kB +0.39% 14.07 kB 14.13 kB
oss-stable-rc/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.browser.development.js +0.69% 74.55 kB 75.06 kB +0.40% 14.11 kB 14.17 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.browser.development.js +0.69% 74.55 kB 75.06 kB +0.40% 14.11 kB 14.17 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.browser.development.js +0.69% 74.55 kB 75.06 kB +0.40% 14.11 kB 14.17 kB
oss-stable-rc/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js +0.68% 75.00 kB 75.51 kB +0.36% 14.24 kB 14.30 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js +0.68% 75.00 kB 75.51 kB +0.36% 14.24 kB 14.30 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js +0.68% 75.00 kB 75.51 kB +0.36% 14.24 kB 14.30 kB
oss-stable-rc/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js +0.64% 83.03 kB 83.56 kB +0.28% 15.60 kB 15.64 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js +0.64% 83.03 kB 83.56 kB +0.28% 15.60 kB 15.64 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js +0.64% 83.03 kB 83.56 kB +0.28% 15.60 kB 15.64 kB
oss-stable-rc/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.development.js +0.64% 79.95 kB 80.46 kB +0.20% 15.26 kB 15.29 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.development.js +0.64% 79.95 kB 80.46 kB +0.20% 15.26 kB 15.29 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.development.js +0.64% 79.95 kB 80.46 kB +0.20% 15.26 kB 15.29 kB
oss-stable-rc/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js +0.64% 83.81 kB 84.35 kB +0.25% 15.78 kB 15.82 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js +0.64% 83.81 kB 84.35 kB +0.25% 15.78 kB 15.82 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js +0.64% 83.81 kB 84.35 kB +0.25% 15.78 kB 15.82 kB
oss-stable-rc/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js +0.63% 81.31 kB 81.82 kB +0.24% 15.53 kB 15.56 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js +0.63% 81.31 kB 81.82 kB +0.24% 15.53 kB 15.56 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js +0.63% 81.31 kB 81.82 kB +0.24% 15.53 kB 15.56 kB
oss-stable-rc/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.development.js +0.63% 81.33 kB 81.84 kB +0.23% 15.51 kB 15.54 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.development.js +0.63% 81.33 kB 81.84 kB +0.23% 15.51 kB 15.54 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.development.js +0.63% 81.33 kB 81.84 kB +0.23% 15.51 kB 15.54 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-server.node.development.js +0.55% 135.75 kB 136.50 kB +0.95% 25.25 kB 25.49 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.browser.development.js +0.54% 138.96 kB 139.71 kB +0.88% 25.80 kB 26.02 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js +0.54% 139.58 kB 140.33 kB +0.87% 25.97 kB 26.20 kB
oss-stable-rc/react-server-dom-esm/cjs/react-server-dom-esm-client.node.development.js +0.53% 77.74 kB 78.15 kB +0.20% 14.78 kB 14.81 kB
oss-stable-semver/react-server-dom-esm/cjs/react-server-dom-esm-client.node.development.js +0.53% 77.74 kB 78.15 kB +0.20% 14.78 kB 14.81 kB
oss-stable/react-server-dom-esm/cjs/react-server-dom-esm-client.node.development.js +0.53% 77.74 kB 78.15 kB +0.20% 14.78 kB 14.81 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.development.js +0.53% 141.03 kB 141.78 kB +0.89% 26.12 kB 26.35 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js +0.53% 141.18 kB 141.93 kB +0.89% 26.18 kB 26.41 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.unbundled.development.js +0.53% 142.11 kB 142.86 kB +0.88% 26.23 kB 26.46 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js +0.53% 142.28 kB 143.03 kB +0.89% 26.29 kB 26.52 kB
oss-stable-rc/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.unbundled.development.js +0.52% 79.15 kB 79.56 kB +0.21% 15.08 kB 15.11 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.unbundled.development.js +0.52% 79.15 kB 79.56 kB +0.21% 15.08 kB 15.11 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.unbundled.development.js +0.52% 79.15 kB 79.56 kB +0.21% 15.08 kB 15.11 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.development.js +0.52% 143.22 kB 143.97 kB +0.87% 26.49 kB 26.72 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js +0.52% 143.37 kB 144.12 kB +0.87% 26.55 kB 26.78 kB
oss-stable-rc/react-server-dom-esm/esm/react-server-dom-esm-client.browser.development.js +0.21% 103.59 kB 103.80 kB = 23.34 kB 23.32 kB
oss-stable-semver/react-server-dom-esm/esm/react-server-dom-esm-client.browser.development.js +0.21% 103.59 kB 103.80 kB = 23.34 kB 23.32 kB
oss-stable/react-server-dom-esm/esm/react-server-dom-esm-client.browser.development.js +0.21% 103.59 kB 103.80 kB = 23.34 kB 23.32 kB
oss-experimental/react-server-dom-esm/esm/react-server-dom-esm-client.browser.development.js = 110.12 kB 109.89 kB = 24.81 kB 24.65 kB

Generated by 🚫 dangerJS against ec47303

@@ -178,18 +178,29 @@ export type Awaited<T> = T extends null | void
: T // argument was not an object
: T; // non-thenable

export type ReactCallSite = [
string, // function name
string, // file name TODO: model nested eval locations as nested arrays
Copy link
Collaborator

Choose a reason for hiding this comment

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

👀

Copy link
Collaborator Author

@sebmarkbage sebmarkbage Jul 22, 2024

Choose a reason for hiding this comment

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

I figured the model could maybe be:

export type ReactCallSite = [
  string, // function name
  string | ReactCallSite, // file name or eval
  number, // line
  number, // column
]

Where if it's a nested callsite that implies it's eval at that location.

All servers currently use the V8 format. Including Bun, which overrides
the JSC format to V8 format it seems.

However, we might need to configure this for the FB build. Conceptually it's
also just something that is environment specific.

I now apply filtering on the result which needs to update some hacks.
@sebmarkbage sebmarkbage merged commit 0676385 into facebook:main Jul 22, 2024
187 checks passed
sebmarkbage added a commit that referenced this pull request Jul 22, 2024
Stacked on #30410.

Use "owner stacks" as the appended component stack if it is available on
the Fiber. This will only be available if the enableOwnerStacks flag is
on. Otherwise it fallback to parent stacks. In prod, there's no owner so
it's never added there.

I was going back and forth on whether to inject essentially
`captureOwnerStack` as part of the DevTools hooks or replicate the
implementation but decided to replicate the implementation.

The DevTools needs all the same information from internals to implement
owner views elsewhere in the UI anyway so we're not saving anything in
terms of the scope of internals. Additionally, we really need this
information for non-current components as well like "rendered by" views
of the currently selected component.

It can also be useful if we need to change the format after the fact
like we did for parent stacks in:
#30289

Injecting the implementation would lock us into specifics both in terms
of what the core needs to provide and what the DevTools can use.

The implementation depends on the technique used in #30369 which tags
frames to strip out with `react-stack-bottom-frame`. That's how the
implementation knows how to materialize the error if it hasn't already.

Firefox:

<img width="487" alt="Screenshot 2024-07-21 at 11 33 37 PM"
src="https://github.com/user-attachments/assets/d3539b53-4578-4fdd-af25-25698b2bcc7d">

Follow up: One thing about this view is that it doesn't include the
current actual synchronous stack. When I used to append these I would
include both the real current stack and the owner stack. That's because
the owner stack doesn't include the name of the currently executing
component. I'll probably inject the current stack too in addition to the
owner stack. This is similar to how native Async Stacks are basically
just appended onto the current stack rather than its own.
sebmarkbage added a commit that referenced this pull request Jul 22, 2024
…rialized (#30416)

Stacked on #30410.

If we've parsed another RSC stream on the server from a different RSC
server, while using `findSourceMapURL`, the Flight Client ends up adding
a `rsc://React/` prefix and a numeric suffix to the URL. It's a virtual
file that represents the virtual eval:ed frame in that environment.

If we then see that same stack again, we'd serialize a virtual frame to
another virtual. Meaning `findSourceMapURL` on the client would see the
virtual frame of the intermediate server and it would have to strip it
to figure out what source map to use.

This PR strips it in the Server if we see a virtual frame. At each new
client it always refers to the original stack.

We don't have to do this. We could leave it to each `findSourceMapURL`
implementation and `captureOwnerStack` parser to recursively strip each
layer. It could maybe be useful to have the environment name in the
virtual frame to know which server to look for the source map in.
felixshiftellecon added a commit to felixshiftellecon/react that referenced this pull request Jul 24, 2024
…rialized (facebook#30416)

Stacked on facebook#30410.

If we've parsed another RSC stream on the server from a different RSC
server, while using `findSourceMapURL`, the Flight Client ends up adding
a `rsc://React/` prefix and a numeric suffix to the URL. It's a virtual
file that represents the virtual eval:ed frame in that environment.

If we then see that same stack again, we'd serialize a virtual frame to
another virtual. Meaning `findSourceMapURL` on the client would see the
virtual frame of the intermediate server and it would have to strip it
to figure out what source map to use.

This PR strips it in the Server if we see a virtual frame. At each new
client it always refers to the original stack.

We don't have to do this. We could leave it to each `findSourceMapURL`
implementation and `captureOwnerStack` parser to recursively strip each
layer. It could maybe be useful to have the environment name in the
virtual frame to know which server to look for the source map in.
felixshiftellecon added a commit to felixshiftellecon/react that referenced this pull request Jul 24, 2024
Stacked on facebook#30410.

Use "owner stacks" as the appended component stack if it is available on
the Fiber. This will only be available if the enableOwnerStacks flag is
on. Otherwise it fallback to parent stacks. In prod, there's no owner so
it's never added there.

I was going back and forth on whether to inject essentially
`captureOwnerStack` as part of the DevTools hooks or replicate the
implementation but decided to replicate the implementation.

The DevTools needs all the same information from internals to implement
owner views elsewhere in the UI anyway so we're not saving anything in
terms of the scope of internals. Additionally, we really need this
information for non-current components as well like "rendered by" views
of the currently selected component.

It can also be useful if we need to change the format after the fact
like we did for parent stacks in:
facebook#30289

Injecting the implementation would lock us into specifics both in terms
of what the core needs to provide and what the DevTools can use.

The implementation depends on the technique used in facebook#30369 which tags
frames to strip out with `react-stack-bottom-frame`. That's how the
implementation knows how to materialize the error if it hasn't already.

Firefox:

<img width="487" alt="Screenshot 2024-07-21 at 11 33 37 PM"
src="https://github.com/user-attachments/assets/d3539b53-4578-4fdd-af25-25698b2bcc7d">

Follow up: One thing about this view is that it doesn't include the
current actual synchronous stack. When I used to append these I would
include both the real current stack and the owner stack. That's because
the owner stack doesn't include the name of the currently executing
component. I'll probably inject the current stack too in addition to the
owner stack. This is similar to how native Async Stacks are basically
just appended onto the current stack rather than its own.
felixshiftellecon added a commit to felixshiftellecon/react that referenced this pull request Jul 24, 2024
…ebook#30410)

Stacked on facebook#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
…rialized (facebook#30416)

Stacked on facebook#30410.

If we've parsed another RSC stream on the server from a different RSC
server, while using `findSourceMapURL`, the Flight Client ends up adding
a `rsc://React/` prefix and a numeric suffix to the URL. It's a virtual
file that represents the virtual eval:ed frame in that environment.

If we then see that same stack again, we'd serialize a virtual frame to
another virtual. Meaning `findSourceMapURL` on the client would see the
virtual frame of the intermediate server and it would have to strip it
to figure out what source map to use.

This PR strips it in the Server if we see a virtual frame. At each new
client it always refers to the original stack.

We don't have to do this. We could leave it to each `findSourceMapURL`
implementation and `captureOwnerStack` parser to recursively strip each
layer. It could maybe be useful to have the environment name in the
virtual frame to know which server to look for the source map in.
felixshiftellecon added a commit to felixshiftellecon/react that referenced this pull request Jul 24, 2024
Stacked on facebook#30410.

Use "owner stacks" as the appended component stack if it is available on
the Fiber. This will only be available if the enableOwnerStacks flag is
on. Otherwise it fallback to parent stacks. In prod, there's no owner so
it's never added there.

I was going back and forth on whether to inject essentially
`captureOwnerStack` as part of the DevTools hooks or replicate the
implementation but decided to replicate the implementation.

The DevTools needs all the same information from internals to implement
owner views elsewhere in the UI anyway so we're not saving anything in
terms of the scope of internals. Additionally, we really need this
information for non-current components as well like "rendered by" views
of the currently selected component.

It can also be useful if we need to change the format after the fact
like we did for parent stacks in:
facebook#30289

Injecting the implementation would lock us into specifics both in terms
of what the core needs to provide and what the DevTools can use.

The implementation depends on the technique used in facebook#30369 which tags
frames to strip out with `react-stack-bottom-frame`. That's how the
implementation knows how to materialize the error if it hasn't already.

Firefox:

<img width="487" alt="Screenshot 2024-07-21 at 11 33 37 PM"
src="https://github.com/user-attachments/assets/d3539b53-4578-4fdd-af25-25698b2bcc7d">

Follow up: One thing about this view is that it doesn't include the
current actual synchronous stack. When I used to append these I would
include both the real current stack and the owner stack. That's because
the owner stack doesn't include the name of the currently executing
component. I'll probably inject the current stack too in addition to the
owner stack. This is similar to how native Async Stacks are basically
just appended onto the current stack rather than its own.
felixshiftellecon added a commit to felixshiftellecon/react that referenced this pull request Jul 24, 2024
…ebook#30410)

Stacked on facebook#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.
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.

4 participants