-
Notifications
You must be signed in to change notification settings - Fork 24.8k
[general][changed] cleanup RedBox message and stack output #24662
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
React/Modules/RCTRedBox.m
Outdated
- (void)showErrorMessage:(NSString *)message withStack:(NSArray<RCTJSStackFrame *> *)stack isUpdate:(BOOL)isUpdate | ||
{ | ||
// Remove ANSI color codes from the message | ||
NSString * messageWithoutAnsi = [self stripAnsi:message]; |
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.
*messageWithoutAnsi
Thank you so much for doing this, this is a great start and makes stack traces so much cleaner. My only concern is about debugging React/React Native changes because when errors do happen, having them stripped out of those files may give a wrong impression to people. Do you think we could add a button at the bottom of the trace, using the same styling as a stack trace to be unobtrusive, that will show hidden parts of the stack when tapped? |
Definitely. Thought about it, but since it involves writing stateful UI logic on both platforms, I decided to go with this as a PoC for now. Happy to give it a spin next week (I'm on vacation starting today.) |
Enjoy your vacation! I think we can ship this for now as it is a good improvement and I'm gonna give others on the RN team a heads up in case they are doing a React sync soon so they are aware that a redbox is excluding some things. |
Libraries/Core/ExceptionsManager.js
Outdated
@@ -12,6 +12,8 @@ | |||
|
|||
import type {ExtendedError} from 'parseErrorStack'; | |||
|
|||
const INTERNAL_CALLSITES_REGEX = /ReactNativeRenderer-dev\.js|MessageQueue\.js/; |
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.
Actually should we make this an exact match with ^
and $
?
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.
For now I've added the $
but I'm going to compare how the paths look in normal app vs RNTester, because they differ.
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.
Adjusted the paths: eb97ee3. They're now generated from an array, so it should be easier to add new ones (or generalize more, we'll see about that).
663f8c6
to
eb97ee3
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.
@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Awesome. Thanks |
Could we do one more thing, and put the text in the red part monospace? At least the part with the line numbers like 30, 31, etc in the first example. |
This pull request was successfully merged by @thymikee in 49d26eb. When will my fix make it into a release? | Upcoming Releases |
@pvinis to quote myself: "I thought about using monospace font for title with code frame, but it looks weird". I can play with that later though |
Oops, I forgot about this parenthesis while looking at the rest :p |
This will make things so much better, thanks! As @cpojer mentioned, it will be pretty important to be able to see the hidden frames. Whenever we do react syncs, those frames are how we debit issues in the renderer. Hopefully you can do a quick follow up to add that. |
@pvinis I think it works for the code frame but not so well for the rest. |
true. I'll try with only the code frame. it was a quick try. maybe I make a PR for it and we see there. thanks :) |
Summary: Cleanup RedBox messages and stack traces. This PR consists of 2 changes (I'm good with splitting them up if you'd like): - [general] filter out some of the internal callsites from the symbolicated stack (I thought about using monospace font for title with code frame, but it looks weird) - [ios][android] strip ANSI characters (coming from colored Babel code frame) from the error message I think it's ok to strip it inside native handlers so we can still have a colorful code frame in the terminal output. **JS Code frame:** |before|after| |--|--| |<img width="400" alt="Screenshot 2019-04-30 at 12 32 05" src="https://user-images.githubusercontent.com/5106466/56956590-ef678d80-6b44-11e9-9019-6801f050ab0d.png">|<img width="400" alt="Screenshot 2019-04-30 at 12 52 43" src="https://user-images.githubusercontent.com/5106466/56957302-f42d4100-6b46-11e9-869b-ea9c7ce5b90f.png">| |before|after| |--|--| ||| **Filtered stack traces:** |before|after| |--|--| |<img width="50%" alt="Screenshot 2019-04-30 at 12 27 21" src="https://user-images.githubusercontent.com/5106466/56956641-0908d500-6b45-11e9-8cdc-8c2a34a071e5.png"><img width="50%" alt="Screenshot 2019-04-30 at 12 27 28" src="https://user-images.githubusercontent.com/5106466/56956642-0908d500-6b45-11e9-921c-fabfb8515cc0.png">|<img width="100%" alt="Screenshot 2019-04-30 at 12 26 55" src="https://user-images.githubusercontent.com/5106466/56956650-0efeb600-6b45-11e9-9f5f-f10dd69580d1.png">| There's still a lot of places that are hard to read, but I think this is a good start towards more readable errors. cc cpojer [General][Changed] - Cleanup RedBox message and stack output Pull Request resolved: facebook/react-native#24662 Differential Revision: D15147571 Pulled By: cpojer fbshipit-source-id: 1de4e521af988fa7fc709b6accd0ddd984388e72
Summary: Cleanup RedBox messages and stack traces. This PR consists of 2 changes (I'm good with splitting them up if you'd like): - [general] filter out some of the internal callsites from the symbolicated stack (I thought about using monospace font for title with code frame, but it looks weird) - [ios][android] strip ANSI characters (coming from colored Babel code frame) from the error message I think it's ok to strip it inside native handlers so we can still have a colorful code frame in the terminal output. **JS Code frame:** |before|after| |--|--| |<img width="400" alt="Screenshot 2019-04-30 at 12 32 05" src="https://user-images.githubusercontent.com/5106466/56956590-ef678d80-6b44-11e9-9019-6801f050ab0d.png">|<img width="400" alt="Screenshot 2019-04-30 at 12 52 43" src="https://user-images.githubusercontent.com/5106466/56957302-f42d4100-6b46-11e9-869b-ea9c7ce5b90f.png">| |before|after| |--|--| ||| **Filtered stack traces:** |before|after| |--|--| |<img width="50%" alt="Screenshot 2019-04-30 at 12 27 21" src="https://user-images.githubusercontent.com/5106466/56956641-0908d500-6b45-11e9-8cdc-8c2a34a071e5.png"><img width="50%" alt="Screenshot 2019-04-30 at 12 27 28" src="https://user-images.githubusercontent.com/5106466/56956642-0908d500-6b45-11e9-921c-fabfb8515cc0.png">|<img width="100%" alt="Screenshot 2019-04-30 at 12 26 55" src="https://user-images.githubusercontent.com/5106466/56956650-0efeb600-6b45-11e9-9f5f-f10dd69580d1.png">| There's still a lot of places that are hard to read, but I think this is a good start towards more readable errors. cc cpojer [General][Changed] - Cleanup RedBox message and stack output Pull Request resolved: facebook/react-native#24662 Differential Revision: D15147571 Pulled By: cpojer fbshipit-source-id: 1de4e521af988fa7fc709b6accd0ddd984388e72
@pvinis If you could use a regular expression to detect the character range of the code frame (excluding the preceding error message), that would be great! |
Summary: Changes `ExceptionsManager` to respect the `collapse` field in each symbolicated stack frame returned from Metro, in preference to the client-side regex. This is ultimately driven by a Metro config option (now also set in the RN new project template). Note that the client-side regex is intentionally ignored for any frame where `collapse` is present ( = all of them if using the latest Metro). Also updates the client-side regex to match the new renderer paths. This is part of a redesign of work done originally in facebook#24662; we will eventually remove the client-side regex from RN. Reviewed By: cpojer Differential Revision: D16500277 fbshipit-source-id: 85a94712a3686f8efcb04fca7814e99cf9726c10
Summary: Pull Request resolved: #435 Adds the `symbolicator.customizeFrame` config option to Metro. This is a function that receives a symbolicated stack frame and can modify the response before it's sent back to the client. The `collapse` field is the first supported customization, intended for auto-collapsing "internal" or infra-related stack frames. This is a redesign of work done originally in facebook/react-native#24662; we will eventually remove the client-side regex from RN. Reviewed By: cpojer Differential Revision: D16499755 fbshipit-source-id: eb748ac74ceee8a9069eac9df4f1be4c2564fdcd
…#25839) Summary: Pull Request resolved: facebook#25839 Changes `ExceptionsManager` to respect the `collapse` field in each symbolicated stack frame returned from Metro, in preference to the client-side regex. This is ultimately driven by a Metro config option (now also set in the RN new project template). Note that the client-side regex is intentionally ignored for any frame where `collapse` is present ( = all of them if using the latest Metro). Also updates the client-side regex to match the new renderer paths. This is part of a redesign of work done originally in facebook#24662; we will eventually remove the client-side regex from RN. Reviewed By: cpojer Differential Revision: D16500277 fbshipit-source-id: 557f93129d334b719200dc8603cc2345ffb45102
Summary: Changes `ExceptionsManager` to respect the `collapse` field in each symbolicated stack frame returned from Metro. This is ultimately driven by a Metro config option (which will have a default set in react-native-community/cli#596). This is part of a redesign of work done originally in facebook#24662. Reviewed By: cpojer Differential Revision: D16500277 fbshipit-source-id: bded9a7b037b9f944b27125d43e35fcce5bd109a
Summary: Pull Request resolved: #25839 Changes `ExceptionsManager` to respect the `collapse` field in each symbolicated stack frame returned from Metro. This is ultimately driven by a Metro config option (which will have a default set in react-native-community/cli#596). This is part of a redesign of work done originally in #24662. Reviewed By: cpojer Differential Revision: D16500277 fbshipit-source-id: b0b035618cb000935a555796523637b5f0a688d3
Summary: Cleanup RedBox messages and stack traces. This PR consists of 2 changes (I'm good with splitting them up if you'd like): - [general] filter out some of the internal callsites from the symbolicated stack (I thought about using monospace font for title with code frame, but it looks weird) - [ios][android] strip ANSI characters (coming from colored Babel code frame) from the error message I think it's ok to strip it inside native handlers so we can still have a colorful code frame in the terminal output. **JS Code frame:** |before|after| |--|--| |<img width="400" alt="Screenshot 2019-04-30 at 12 32 05" src="https://user-images.githubusercontent.com/5106466/56956590-ef678d80-6b44-11e9-9019-6801f050ab0d.png">|<img width="400" alt="Screenshot 2019-04-30 at 12 52 43" src="https://user-images.githubusercontent.com/5106466/56957302-f42d4100-6b46-11e9-869b-ea9c7ce5b90f.png">| |before|after| |--|--| ||| **Filtered stack traces:** |before|after| |--|--| |<img width="50%" alt="Screenshot 2019-04-30 at 12 27 21" src="https://user-images.githubusercontent.com/5106466/56956641-0908d500-6b45-11e9-8cdc-8c2a34a071e5.png"><img width="50%" alt="Screenshot 2019-04-30 at 12 27 28" src="https://user-images.githubusercontent.com/5106466/56956642-0908d500-6b45-11e9-921c-fabfb8515cc0.png">|<img width="100%" alt="Screenshot 2019-04-30 at 12 26 55" src="https://user-images.githubusercontent.com/5106466/56956650-0efeb600-6b45-11e9-9f5f-f10dd69580d1.png">| There's still a lot of places that are hard to read, but I think this is a good start towards more readable errors. cc cpojer [General][Changed] - Cleanup RedBox message and stack output Pull Request resolved: facebook/react-native#24662 Differential Revision: D15147571 Pulled By: cpojer fbshipit-source-id: 1de4e521af988fa7fc709b6accd0ddd984388e72
Summary
Cleanup RedBox messages and stack traces. This PR consists of 2 changes (I'm good with splitting them up if you'd like):
I think it's ok to strip it inside native handlers so we can still have a colorful code frame in the terminal output.
JS Code frame:
Filtered stack traces:
There's still a lot of places that are hard to read, but I think this is a good start towards more readable errors.
cc @cpojer
Changelog
[General][Changed] - Cleanup RedBox message and stack output
Test Plan
Played around in RNTester