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

Printing a too-long-line causes 100% CPU workloads #246

Open
kikuchan opened this issue Oct 2, 2023 · 0 comments
Open

Printing a too-long-line causes 100% CPU workloads #246

kikuchan opened this issue Oct 2, 2023 · 0 comments

Comments

@kikuchan
Copy link

kikuchan commented Oct 2, 2023

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.

function stringWidth(str: string) {
// https://github.com/unjs/consola/issues/204
if (!Intl.Segmenter) {
return stripAnsi(str).length;
}
return _stringWidth(str);
}

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant