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

Data Race - Subscriptions not concurrent safe #40

Open
exapsy opened this issue Dec 31, 2020 · 1 comment
Open

Data Race - Subscriptions not concurrent safe #40

exapsy opened this issue Dec 31, 2020 · 1 comment

Comments

@exapsy
Copy link

exapsy commented Dec 31, 2020

data race error

Error happens in

https://github.com/functionalfoundry/graphqlws/blob/master/subscriptions.go#L157

Seems like the subscription manager map is not concurrent safe.

@exapsy
Copy link
Author

exapsy commented Feb 19, 2021

I fixed that by converting the map to sync.Map. Although, it required a little bit of an ugly solution as sync.Map doesn't support types. It's a map of interface{} which you have to dynamically check outside compile time if they're the right type. You can find the solution here

https://github.com/exapsy/graphqlws/blob/master/subscriptions.go

It actually solved a data-race problem of mine which crashed the entire frontend which was supported by the golang graphql server, which is nice.

But I think it's an ugly solution to serve to the public so I wont make a PR unless someone thinks it's alright. From what I see this repository's maintainers are inactive anyways so a PR probably wouldn't serve anyone :P

But whoever wants to utilize this solution into their code they're free to do so. :)

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