Skip to content
This repository was archived by the owner on May 31, 2023. It is now read-only.

Commit cb32dc9

Browse files
author
Richard Patel
authored
StreamPriceAccounts: fix goroutine leak (#5)
1 parent 0a28d6e commit cb32dc9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

prices.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (c *Client) StreamPriceAccounts(ctx context.Context, updates chan<- PriceAc
4343
default:
4444
return err
4545
}
46-
}, backoff.NewConstantBackOff(retryInterval))
46+
}, backoff.WithContext(backoff.NewConstantBackOff(retryInterval), ctx))
4747
}
4848

4949
func (c *Client) streamPriceAccounts(ctx context.Context, updates chan<- PriceAccountUpdate) error {
@@ -53,6 +53,12 @@ func (c *Client) streamPriceAccounts(ctx context.Context, updates chan<- PriceAc
5353
}
5454
defer client.Close()
5555

56+
// Make sure client cannot outlive context.
57+
go func() {
58+
defer client.Close()
59+
<-ctx.Done()
60+
}()
61+
5662
metricsWsActiveConns.Inc()
5763
defer metricsWsActiveConns.Dec()
5864

0 commit comments

Comments
 (0)