Skip to content

Commit 02196f9

Browse files
nathanmmillersheremet-va
andauthoredJun 15, 2023
fix: avoid call stack recursion with large error (fix: #3060) (#3078)
Co-authored-by: Vladimir <sleuths.slews0s@icloud.com>
1 parent 3d43638 commit 02196f9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed
 

‎packages/vitest/src/node/error.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,13 @@ export function displayDiff(diff: string, console: Console) {
190190

191191
function printErrorMessage(error: ErrorWithDiff, logger: Logger) {
192192
const errorName = error.name || error.nameStr || 'Unknown Error'
193-
logger.error(c.red(`${c.bold(errorName)}: ${error.message}`))
193+
if (error.message.length > 5000) {
194+
// Protect against infinite stack trace in picocolors
195+
logger.error(`${c.red(c.bold(errorName))}: ${error.message}`)
196+
}
197+
else {
198+
logger.error(c.red(`${c.bold(errorName)}: ${error.message}`))
199+
}
194200
}
195201

196202
function printStack(

0 commit comments

Comments
 (0)
Please sign in to comment.