The server-side request handlers send back responses through a finished channel. If the stream is cancelled, this channel can block and cause deadlocks or leak goroutines. To fix this, we can use a select statement to block until the response can be sent on the finished channel or until the stream context is cancelled.
The server-side request handlers send back responses through a
finished
channel. If the stream is cancelled, this channel can block and cause deadlocks or leak goroutines. To fix this, we can use a select statement to block until the response can be sent on thefinished
channel or until the stream context is cancelled.