-
Notifications
You must be signed in to change notification settings - Fork 133
Description
I had some code that was using goroutines to receive data from other systems (using JSON-RPC 2.0 over WebSocket) and send that data over a streaming RPC connection, and I had an issue that sometimes some of the data would never be received.
I stumbled across this discussion, which says:
I know this isn't called out well in the docs, so we need to update doc comments to make it more clear. But there is a subtle mention of this here: https://pkg.go.dev/connectrpc.com/connect#StreamingClientConn
Basically, multiple concurrent calls to Send could be a race condition and should be protected by a mutex. ...
I never would have thought of checking the documentation for the StreamingClientConn interface when troubleshooting a server (i.e. using the StreamingHandlerConn interface).
In my case, switching to use a single sending goroutine and a channel was the correct solution, but I think this really needs to be added to the documentation, because it's not clear at all that Send isn't thread-safe.
I'm happy to make a PR for it, but I wanted to see if anyone else is already doing it before I take the time.