Commit 5f7e31ce authored by protolambda's avatar protolambda Committed by GitHub

op-supervisor: add logging for RPC subscription state changes (#13632)

parent 709e1bf9
......@@ -113,13 +113,23 @@ func (m *ManagedNode) SubscribeToNodeEvents() {
// Resubscribe, since the RPC subscription might fail intermittently.
// And fall back to polling, if RPC subscriptions are not supported.
m.subscriptions = append(m.subscriptions, gethevent.ResubscribeErr(time.Second*10,
func(ctx context.Context, _ error) (gethevent.Subscription, error) {
func(ctx context.Context, prevErr error) (gethevent.Subscription, error) {
if prevErr != nil {
// This is the RPC runtime error, not the setup error we have logging for below.
m.log.Error("RPC subscription failed, restarting now", "err", prevErr)
}
sub, err := m.Node.SubscribeEvents(ctx, m.nodeEvents)
if err != nil {
if errors.Is(err, gethrpc.ErrNotificationsUnsupported) {
m.log.Warn("No RPC notification support detected, falling back to polling")
// fallback to polling if subscriptions are not supported.
return rpc.StreamFallback[types.ManagedEvent](
sub, err := rpc.StreamFallback[types.ManagedEvent](
m.Node.PullEvent, time.Millisecond*100, m.nodeEvents)
if err != nil {
m.log.Error("Failed to start RPC stream fallback", "err", err)
return nil, err
}
return sub, err
}
return nil, err
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment