Skip to content

Commit

Permalink
fix: avoid call stack recursion with large error
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanmmiller committed Mar 25, 2023
1 parent efb91e2 commit 9e2e5b9
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(actual: string, expected: 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 9e2e5b9

Please sign in to comment.