Proposal: make client safe for concurrent calls when using custom decode config
- 主要语言
- Go
- 星标
- 10.8k
- 派生
- 1.3k
- 平均合并
- 2 天 36 分钟
- 30 天内合并 PR
- 26
描述
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!
贡献指南
评估
这个 Issue 还没有评估数据。