Skip to content

reconnect_attempt not reset to 0 after successful retry #81

Closed

Description

@pascalbetz

If we have multiple reconnect attempts (e.g. reconnect_attempts = 5) and there is a connection issue in the #listen loop then the reconnect_attempt is increased but never resetted to 0 upon successful reconnect.

Is this intended? (i.e. total number of reconnection attempts while process is alive) or should this be reset to 0 (number of reconnects after a successful connect to the DB)?

If latter: would this be OK?

            def broadcast_messages
              current_channels = channels.dup

              ::SolidCable::Message.
                broadcastable(current_channels.keys, last_id).
                each do |message|
                  should_broadcast_message = false
                  channels.compute_if_present(message.channel) do |channel_last_id|
                    break if channel_last_id >= message.id

                    should_broadcast_message = true
                    message.id
                  end

                  broadcast(message.channel, message.payload) if should_broadcast_message
                  self.reconnect_attempt = 0 # added
                  self.last_id = message.id
                end
            end

Activity

  1. npezza93 commented on Jun 24, 2026

    @npezza93
    Collaborator

    Ah whoops. Good call yea thats a fine spot to add it. Feel free to open a pr and ill merge

  2. pascalbetz commented on Jun 24, 2026

    @pascalbetz
    ContributorAuthor

    Created an MR. Not sure how to test this properly (besides instance_variable_get) since reconnect_attempt is burried two levels deep without public accessors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions