ensure context is cancelled to prevent goroutine leaks from grpc.newClientStream

Signed-off-by: Cory Bennett <cbennett@netflix.com>
v0.7
Cory Bennett 2020-01-07 14:35:17 -08:00
parent f7cf4823f7
commit 463fc8d1b8
1 changed files with 3 additions and 1 deletions

View File

@ -116,7 +116,9 @@ func newCall(fn func(ctx context.Context) (interface{}, error)) *call {
func (c *call) run() {
defer c.closeProgressWriter()
v, err := c.fn(c.ctx)
ctx, cancel := context.WithCancel(c.ctx)
defer cancel()
v, err := c.fn(ctx)
c.mu.Lock()
c.result = v
c.err = err