-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
process: improve handling of formatted error stack #28291
Conversation
Fatal errors are logged from C++ directly to stderr. If colored stack trace is used, ANSI color escape sequences are literally included in the stack trace string. It works in console on Unix-like systems, but does not work on Windows or in inspector's DevTools. This PR disables colored stack trace for fatal errors.
Ready for review |
@Hakerh400 would it not be better to improve the color detection instead? It seems like a bug in the color detection and not about the output itself. Some Windows terminals and versions do support ANSI codes. It is just not that easy to determine which ones do and which don't. |
@BridgeAR Libuv can already emulate colors on Windows, so Windows is not the problem. The main problem is that fatal errors are delegated to C++ and logged directly to stderr, avoiding color emulation on consoles that do not support colors natively. Improving color support detection on Windows may be a good idea too, but that would not solve this problem, it would rather bring an inconsistency in the output between terminals (colors would not be displayed in some terminals, while libuv has capability to do so). One solution I can think of is to log the error using Still one problem would remain: if the inspector is attached, we should either not color the stack trace, or adapt the colors to the inspector (Chrome DevTools support setting background and foreground color of text). So, I think the two main questions here are 1) Is it a good idea to use |
Doesn't this patch just remove the highlight all the time? If I have to pick, not having colors at all is worse than having ANSI escape sequence in inspector output. |
@joyeecheung This patch currently only removes highlighting of fatal (uncaught) errors, while |
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’m okay with just removing this as a bit of a design smell (we’re performing colour detection without the error only ending up in stdout).
However: I think we can improve the situation without fully removing colour support; e.g. we could not override er.stack
, but instead store it on a separate property (a private one, if we want to fully hide this), and then use that for printing to stderr while at the same time keeping e.g. the inspector fully intact.
On the Windows issue - that should be fairly trivial to fix by using (In fact |
Fatal errors are logged from C++ directly to stderr.
If colored stack trace is used, ANSI color escape sequences
are literally included in the stack trace string. It works
in console on Unix-like systems, but does not work on
Windows or in inspector's DevTools. This PR disables colored
stack trace for fatal errors.
Fixes #28287
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes