-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
Remove top stack frame from getCurrentStack #30306
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
let error; | ||
try { | ||
await act(() => { | ||
root.update( | ||
<Suspense fallback={<Text text="Loading..." />}> | ||
<LazyText text="Hi" /> |
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.
We have a lot of test like this that execute at the top level and so has no owner. Therefore doesn't get any owner stack which means that it doesn't have a component stack which fails our assertions. This is why I usually try to add a single frame if possible. Mainly due to our tests.
This test was relying on the top stack to be able to have a single stack frame at all.
We could maybe also add a "Lazy" frame for a lazy component if there's no other owner.
This is all academic though because it only affects our tests that asserts on component stacks and real apps rarely has no owner.
The full stack is the current execution stack (`new Error().stack`) + the current owner stack (`React.captureOwnerStack()`). The idea with the top frame was that when we append it to console.error we'd include both since otherwise the true reason would be obscured behind the little `>` to expand. So we'd just put both stack front and center. By adding this into getCurrentStack it was easy to use the same filtering. I never implemented in Fizz or Flight though. However, with the public API `React.captureOwnerStack()` it's not necessary to include the current stack since you already have it and you'd have filtering capabilities in user space too. Since I'm removing the component stacks from React itself we no longer need this. It's expected that maybe RDT or framework polyfill would include this same technique though. DiffTrain build for commit 433068e.
The full stack is the current execution stack (`new Error().stack`) + the current owner stack (`React.captureOwnerStack()`). The idea with the top frame was that when we append it to console.error we'd include both since otherwise the true reason would be obscured behind the little `>` to expand. So we'd just put both stack front and center. By adding this into getCurrentStack it was easy to use the same filtering. I never implemented in Fizz or Flight though. However, with the public API `React.captureOwnerStack()` it's not necessary to include the current stack since you already have it and you'd have filtering capabilities in user space too. Since I'm removing the component stacks from React itself we no longer need this. It's expected that maybe RDT or framework polyfill would include this same technique though. DiffTrain build for [433068e](433068e)
The full stack is the current execution stack (
new Error().stack
) + the current owner stack (React.captureOwnerStack()
).The idea with the top frame was that when we append it to console.error we'd include both since otherwise the true reason would be obscured behind the little
>
to expand. So we'd just put both stack front and center. By adding this into getCurrentStack it was easy to use the same filtering. I never implemented in Fizz or Flight though.However, with the public API
React.captureOwnerStack()
it's not necessary to include the current stack since you already have it and you'd have filtering capabilities in user space too.Since I'm removing the component stacks from React itself we no longer need this. It's expected that maybe RDT or framework polyfill would include this same technique though.