Replies: 1 comment
-
Hey @jlewi, I believe this will be from writing in a parallel goroutine after the server handler has returned. You must ensure that any goroutines that send response messages are done before the handler errors. To do this you can use a waitgroup and ensure each goroutine is bound to the lifetime of the handler. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a bidirectional streaming server written in GoLang. I'm getting an error
The full stack trace is in jlewi/foyle#319. The code is here.
IUC this error indicates the server is trying to send the response when the context has already been cancelled leading to the error. I think the bug in my code is that in between when I was checking whether the context was done and when I send the response the context was actually cancelled. So I can move the context.Done channel to write before I call stream.Send.
However, it seems like there might always be some small probability that in between calling context.Done and stream.Send the context gets cancelled. This got me wondering whether I'm doing something more fundamental wrong?
Beta Was this translation helpful? Give feedback.
All reactions