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

Commit 2fcf29e

Browse files
author
Richard Patel
committed
stream: fix deadlock when cancelling subscription
1 parent 5d03562 commit 2fcf29e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

stream.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package pyth
1717
import (
1818
"context"
1919
"errors"
20+
"net"
2021
"sync"
2122
"time"
2223

@@ -153,11 +154,13 @@ func (p *PriceAccountStream) readNextUpdate(ctx context.Context, sub *ws.Program
153154
update, err := sub.Recv()
154155
if err != nil {
155156
return err
157+
} else if update == nil {
158+
return net.ErrClosed
156159
}
157160
metricsWsEventsTotal.Inc()
158161

159162
// Decode update.
160-
if update == nil || update.Value.Account == nil || update.Value.Account.Owner != p.client.Env.Program {
163+
if update.Value.Account == nil || update.Value.Account.Owner != p.client.Env.Program {
161164
return nil
162165
}
163166
accountData := update.Value.Account.Data.GetBinary()

0 commit comments

Comments
 (0)