-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
Uncaught error stack trace is misformatted on some platforms #29387
Comments
For reference #28451 is a failing attempted fix for this - I guess the proper fix should be exposing the color translation from libuv somehow and handle the color translation by ourselves. We can't use a |
What is the status of this issue? Is anyone currently working on it? This is a really nasty bug. |
@DerekNonGeneric I doubt that anyone is actively working on it currently. Do you know if this is still an issue on Windows 10? We might just deactivate colors for Windows 8.1 / could try to detect what terminal is used to deactivate colors there. |
Windows Command Prompt supports ANSI sequences starting from Windows 10 v.1607. [1] [1]: https://api.dart.dev/stable/1.24.3/dart-io/Stdout/supportsAnsiEscapes.html |
/re #33132 (comment) This problem does not appear to be exclusive to cmd.exe (also happens on PowerShell). |
ANSI control codes used to be a built-in in DOS environments...you just had to load ansi.sys from your config.sys file...whatever happened to that? Derek - maybe a temp workaround for you? Found this on stack overflow --
|
@wesgarland, thanks for looking into this! I was able to confirm that the versions of cmd.exe and PowerShell on my system do indeed support ANSI. I used the The ANSI escape sequences are working as expected in cmd.exe and PS when using |
The issue is libuv only provides color code translation via
This is because console.log() goes through process.stdout which does We could either expose the color translation code from libuv and do that before we write to stderr directly (without using libuv streams) - the code is quite entangled in the tty write routine so it's not easy to refactor it out though - or use a different color translation facility on Windows. Maybe we could also just close the stream with fd 2 held by process.stderr and then do a |
this is still not fixed. when will this be fixed? the fix is really simple, in the windows C code just add this: #include <windows.h>
void ansi_codes_enable() {
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
if (hOut == INVALID_HANDLE_VALUE) {
return;
}
DWORD dwMode = 0;
if (!GetConsoleMode(hOut, &dwMode)) {
return;
}
dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
SetConsoleMode(hOut, dwMode);
} in case the problem is that ansi codes are not enabled in nodejs for some reason. if that's not the issue, just fix whatever it is. it's really hard to read error messages right now when they don't display correctly and you see the literal ansi codes instead of the effects of what they're supposed to do. |
Some consoles do not convert ANSI escape sequences to colors, rather display them directly to the stdout. On those consoles, libuv emulates colors by intercepting stdout stream and calling corresponding Windows API functions for setting console colors, if needed.
PR #27052 introduced stack trace highlighting, but it bypasses libuv and prints the raw string. It works on Linux and on some Windows console emulators that support ANSI colors, but does not work on most Windows consoles, including the default console (cmd.exe) on Windows 8.1
As pointed out in #28308 (comment), a possible fix is to modify
PrintErrorString()
to useuv_write
. However, I tried different approaches, but can't get all tests to pass. I'm opening this thread so that we at least have a tracking issue for this old bug.The text was updated successfully, but these errors were encountered: