Skip to content
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

errors: skip fatal error highlighting on windows #33132

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 18 additions & 2 deletions lib/internal/errors.js
Expand Up @@ -674,15 +674,31 @@ const fatalExceptionStackEnhancers = {
},
afterInspector(error) {
const originalStack = error.stack;
let useColors = true;
// 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.
// However, fatal error are handled differently and we cannot easily
// highlight them. On Windows, detecting whether a console supports
// ANSI escape sequences is not reliable.
if (process.platform === 'win32') {
const info = internalBinding('os').getOSInformation();
const ver = info[2].split('.').map((a) => +a);
if (ver[0] !== 10 || ver[2] < 14393) {
useColors = false;
}
}
BridgeAR marked this conversation as resolved.
Show resolved Hide resolved
const {
inspect,
inspectDefaultOptions: {
colors: defaultColors
}
} = lazyInternalUtilInspect();
const colors = (internalBinding('util').guessHandleType(2) === 'TTY' &&
const colors = useColors &&
((internalBinding('util').guessHandleType(2) === 'TTY' &&
require('internal/tty').hasColors()) ||
defaultColors;
defaultColors);
try {
return inspect(error, { colors });
} catch {
Expand Down