99designs / 99designs/gqlgen

Proposal: make client safe for concurrent calls when using custom decode config

Offen
#4,084 0 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Go
Sterne
10.8k
Forks
1.3k
Ø Merge
2 T. 36 Min.
Gemergte PRs (30 T.)
26

Beschreibung

I am currently running into a race condition when making concurrent calls to `client.Post`, when the client has a custom decode configuration.
The race happen here: https://github.com/99designs/gqlgen/blob/82bf8457f1df0a7073b5f45ef70e8b95eb09cba8/client/client.go#L166
Since `customDc` is not nil, the `Result` field is being written multiple times.

One way to deal with this would be to allow something like a "decoder factory" - a function to create a new decode config on every call instead of using the same one.
The other solution is to clone the custom decoder before writing the result.
(Another solution for me would be to use separate clients, i.e. fixing it on my side, but I think it can be nice to handle it in the library)
I'd be happy to help with the implementation if needed.
Thanks!

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.