Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TODO: Add a timeout on subscriptions #52

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions node/subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ type subscription struct {
conn Requester
}

var _ Subscription = &subscription{}

func (s *subscription) Response() *jsonrpc.RawResponse {
return s.response
}
Expand Down Expand Up @@ -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
Expand Down