From 3d90eacfb185bb4e968e36aff3deedca1d24df43 Mon Sep 17 00:00:00 2001 From: Ryan Schneider Date: Fri, 11 Jun 2021 11:16:51 -0700 Subject: [PATCH] TODO: Add a timeout on subscriptions --- node/subscription.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/node/subscription.go b/node/subscription.go index 070711b..502efc0 100644 --- a/node/subscription.go +++ b/node/subscription.go @@ -19,6 +19,8 @@ type subscription struct { conn Requester } +var _ Subscription = &subscription{} + func (s *subscription) Response() *jsonrpc.RawResponse { return s.response } @@ -116,6 +118,18 @@ func (s *subscription) dispatch(ctx context.Context, n jsonrpc.Notification) { // of the full struct rahter than a pointer. This is to ensure that this function owns // the pointer that is written to the dispatch channel. + // TODO: Add a timeout: + /* + goroutine profile: total 383412 + 382748 @ 0x4315e0 0x44101b 0x97d270 0x97de8a 0x45ef01 + # 0x97d26f github.com/INFURA/go-ethlibs/node.(*subscription).dispatch+0x14f /go/src/github.com/INFURA/off-chain-logs/vendor/github.com/INFURA/go-ethlibs/node/subscription.go:119 + # 0x97de89 github.com/INFURA/go-ethlibs/node.(*loopingTransport).loop.func1.3+0x139 /go/src/github.com/INFURA/off-chain-logs/vendor/github.com/INFURA/go-ethlibs/node/loop.go:225 + + 104 @ 0x4315e0 0x405b78 0x405b4e 0x40583b 0x97fab4 0x968194 0x45ef01 + # 0x97fab3 github.com/INFURA/go-ethlibs/node.(*loopingTransport).loop.func4+0x53 /go/src/github.com/INFURA/off-chain-logs/vendor/github.com/INFURA/go-ethlibs/node/loop.go:326 + # 0x968193 golang.org/x/sync/errgroup.(*Group).Go.func1+0x63 /go/src/github.com/INFURA/off-chain-logs/vendor/golang.org/x/sync/errgroup/errgroup.go:57 + */ + select { case <-ctx.Done(): // the parent context .dispatch was called ended, we can go ahead and give up