consola
consola copied to clipboard
Printing a too-long-line causes 100% CPU workloads
Environment
Consola v3.2.3
Node v20.7.0 / v18.17.1 Deno v1.36.4
Reproduction
import { consola } from 'consola';
consola.log('x'.repeat(200000));
Describe the bug
Printing a too-long-line causes 100% CPU workloads because of the high cost of Intl.Segmenter
in string-width
used by FancyReporter
.
https://github.com/unjs/consola/blob/059bd6380e55c69d4ae73d3d60aebaf9289eb157/src/reporters/fancy.ts#L40-L46
https://github.com/sindresorhus/string-width/blob/f6e70c4c8de68ea2797a8765f1c7350ef0929a83/index.js#L27
Additional context
This could be a bug or a specification of string-width
, but it is problematic when used as a part of logger.
on Bun 1.0.0, it is safe by the way. (I don't know whether its Intl.Segmenter
is fully functional)
Logs
No response