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

fix: register chroma style once #156

Merged
merged 1 commit into from
Jul 27, 2022
Merged

fix: register chroma style once #156

merged 1 commit into from
Jul 27, 2022

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 toby and muesli July 5, 2022 22:25
@muesli
Copy link
Member

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
Member

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.

None yet

2 participants