turbo icon indicating copy to clipboard operation
turbo copied to clipboard

[turborepo] Logging colors are non-deterministic

Open preynal opened this issue 3 years ago • 4 comments

What version of Turborepo are you using?

1.6.3

What package manager are you using / does the bug impact?

Yarn v1

What operating system are you using?

Mac

Describe the Bug

CLI colors are changing between runs for the same package. It sure looks pretty for VC demos, but is very confusing, as a user expects the package name to have the same color between consecutive runs.

Screenshot 2022-11-02 at 17 22 32 Screenshot 2022-11-02 at 17 23 05

Expected Behavior

Colors of a package name in the CLI must remain the same no matter when or where you run the CLI

To Reproduce

Run a turbo repo command twice, the colours will randomly change.

Reproduction Repo

No response

preynal avatar Nov 02 '22 16:11 preynal

I believe this is not deterministic because the order of tasks running is also not deterministic (by design). We could base the color on the task name itself to make it deterministic, but I'm not sure how we'd support an unbounded number of colors (I'm sure it's possible, just not sure off the top of my head what's available)

The code is here:

https://github.com/vercel/turbo/blob/261d22177f6c7301f9c5e93518112b025b15d7aa/cli/internal/colorcache/colorcache.go#L33-L45

mehulkar avatar Nov 02 '22 17:11 mehulkar

wouldn't have to be unbound could just hash to an integer and modulus to the number of colors to least stay consistent. just a thought (i noticed this even for a single task)

scamden avatar Jan 07 '23 00:01 scamden

I just had a build fail and was left typing invisible characters into the shell prompt. My background was black, so maybe the characters were also black.

jtlapp avatar Feb 09 '23 13:02 jtlapp

What's even more undesirable is even the replayed output from a >>> FULL TURBO cached run does not yield a deterministic color 😢.

I'd imagine with the port to rust it would be a good idea to make the color be derived from the package/task name.

cc @anthonyshew since were talking about this the other day.

Hacksore avatar Apr 06 '23 17:04 Hacksore