Skip to content

Conversation

@aymanbagabas
Copy link
Member

don't register chroma style if it's already registered

this could cause a "concurrent map writes" fatal error when used in a
concurrent setting like a bubbletea wish app

@aymanbagabas aymanbagabas requested review from muesli and toby July 5, 2022 22:25
@muesli
Copy link
Contributor

muesli commented Jul 7, 2022

I wonder if this is the right place to fix this. Maybe the styles map should be a sync.Map to allow for concurrent access? Alternatively the locking could probably be done in styles.Register and styles.Get itself.

@aymanbagabas
Copy link
Member Author

@muesli
Copy link
Contributor

muesli commented Jul 11, 2022

Nice, let's see what @alecthomas thinks about this. There might be other areas of chroma that aren't concurrency-safe, so it may or may not make sense to do this. We can still follow this PR otherwise.

don't register chroma style if it's already registered

this could cause a "concurrent map writes" fatal error when used in a
concurrent setting like a bubbletea wish app. use a package-wide mutex
to protect registering a new style.
@muesli muesli merged commit a99aac8 into master Jul 27, 2022
@muesli muesli deleted the fix-register-style branch July 27, 2022 18:34
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

Successfully merging this pull request may close these issues.

3 participants