Skip to content

Commit

Permalink
fix: avoid call stack recursion with large error (fix: #3060) (#3078)
Browse files Browse the repository at this point in the history
Co-authored-by: Vladimir <sleuths.slews0s@icloud.com>
  • Loading branch information
nathanmmiller and sheremet-va committed Jun 15, 2023
1 parent 3d43638 commit 02196f9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/vitest/src/node/error.ts
Expand Up @@ -190,7 +190,13 @@ export function displayDiff(diff: string, console: Console) {

function printErrorMessage(error: ErrorWithDiff, logger: Logger) {
const errorName = error.name || error.nameStr || 'Unknown Error'
logger.error(c.red(`${c.bold(errorName)}: ${error.message}`))
if (error.message.length > 5000) {
// Protect against infinite stack trace in picocolors
logger.error(`${c.red(c.bold(errorName))}: ${error.message}`)
}
else {
logger.error(c.red(`${c.bold(errorName)}: ${error.message}`))
}
}

function printStack(
Expand Down

0 comments on commit 02196f9

Please sign in to comment.