create-react-app: Question: Source mapping componentStack from error boundary in production
Lately, I am trying to use error boundaries to tackle unexpected errors more properly. I am also logging most of the errors to the Sentry service. I am sending the componentStack
from componentDidMount
there as well, but since it’s minified, it feels fairly useless.
I am wondering what are my options if any. Since that output is pretty much just a string, the source mapping does not seem possible at any level.
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 15
- Comments: 29 (6 by maintainers)
Oh come on, I hate this little blue thing. Just because there is no viable answer yet, it shouldn’t be stale 😦 This is a real issue. Can someone please tell that robot it’s ok to keep it open?
Hi @iansu are the any updates on this issue? This is a significant for those of us who want to use error boundary to log errors.
@iansu That surely won’t work because the
componentStack
is just a string, there is no structured information to feed source mapping mechanism. Have a look at this example (used to showcase different issue).https://codesandbox.io/s/zw500lpm2p
@Tonyce That’s really nice of you that you want to share your solution …
Duplicate of https://github.com/facebook/create-react-app/issues/3753
You can upload your sourcemaps to Sentry. That might help in this situation.
I don’t think we want to include something like this by default as it will increase the bundle size for everyone. So if something like this will be included it needs to be opt-in but I don’t know if we want to go down that road of making the babel setup configurable.
I’ll open this again as a proposal and see what other maintainers think of this.
@FredyC In the same doc (https://reactjs.org/docs/error-boundaries.html#component-stack-traces) they also mentioned
displayName
property that can be used to get a proper component name displayed in the stack traces.There’s a babel plugin that allows to get a name with relative file path prefix in production.
Well, I have got my solution. Could get the stack str from error. Thanks