-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Reference docs for captureOwnerStack
#7427
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Size changes📦 Next.js Bundle Analysis for react-devThis analysis was generated by the Next.js Bundle Analysis action. 🤖 One Page Changed SizeThe following page changed size from the code in this PR compared to its base branch:
DetailsOnly the gzipped size is provided here based on an expert tip. First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If Any third party scripts you have added directly to your app using the Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 10% or more, there will be a red status indicator applied, indicating that special attention should be given to this. |
4a08a62
to
4bf159b
Compare
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 the naming we should go with is:
- Component Stack: what you're calling "parent component stack" here
- Owner Stack: what you're calling "owner component stack" here
* **optional** `onCaughtError`: Callback called when React catches an error in an Error Boundary. Called with the `error` caught by the Error Boundary, and an `errorInfo` object containing the `componentStack`. | ||
* **optional** `onUncaughtError`: Callback called when an error is thrown and not caught by an Error Boundary. Called with the `error` that was thrown, and an `errorInfo` object containing the `componentStack`. | ||
* **optional** `onRecoverableError`: Callback called when React automatically recovers from errors. Called with an `error` React throws, and an `errorInfo` object containing the `componentStack`. Some recoverable errors may include the original error cause as `error.cause`. | ||
* **optional** `onCaughtError`: Callback called when React catches an error in an Error Boundary. Called with the `error` caught by the Error Boundary, and an `errorInfo` object containing the parent Component stack in `componentStack`. |
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.
What is a "parent Component Stack" isn't that just the Component Stack? Adding "parent" makes it sound like it doesn't include the component that errored.
This page should also add a usage item for calling captureOwnerStack
to get the owner stack.
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 feel like expanding the existing usages is sufficient. Is that what you meant? Adding a whole new section feels like overkill.
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.
Isn't there a use case for calling it in user land to add to logs? Or should this only be called in the root handlers and error patch?
Aren't we getting rid of parent stacks entirely eventually? I thought the plan was for owner stacks to subsume them. In which case I might still discuss which stack frames you'll see but not emphasize the difference so much. |
Not for production logging. They're the ones passed to the deriveStateFromError/componentDidCatch and onError on the server. They only go away in the standard DEV console.error reporting. |
There should also be runable sandboxes for the Usage examples |
To expand on that — it’s not just for it to be nice but because it’s a proof the API actually works end to end and does what the docs page says it does. We’ve had cases where that wasn’t the case and the Usage examples helped uncover the misunderstandings. |
d6e8d90
to
4f59d78
Compare
4f59d78
to
265786e
Compare
265786e
to
47e7e41
Compare
1bbf3b8
to
86d7eac
Compare
86d7eac
to
ec43819
Compare
It's just a (bad) polyfill for what RDT is doing. Better to lean on RDT for owner stacks in console calls.
root error handlers for prod only captureOwnerStack illustration in patched console.error
ec43819
to
c76a3d3
Compare
Reduced error handler usages to just production logging. Showing a minimal dev overlay in captureOwnerStack usage section that only intercepts |
fa70867
to
053bd5c
Compare
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.
Sick
Pending internal decision to ship in Canary. Still off for FB builds. Docs: reactjs/react.dev#7427
captureOwnerStack
captureOwnerStack
React error handlers now only show production error logging in one example.
captureOwnerStack
docs show usage in an instrumented console.error for a dev overlay. The example with an instrumentedconsole.error
doesn't show interaction with error handlersPreview:
captureOwnerStack
createRoot error handlers
hydrateRoot error handlers
Enabling it on Canary: facebook/react#32053