Subject: bug#62044: 30.0.50; ERC 5.5: Auto-reconnect is broken

From: "J.P." <[email-masked]>
Date: Tue, 07 Mar 2023 23:56:12 -0800

Hi xoddf2,

xoddf2 <[email-masked]> writes:

> Even with the following settings:
>
> (setq erc-server-auto-reconnect t
>       erc-server-reconnect-timeout 10
>       erc-server-reconnect-attempts t)
>
> ERC does not reconnect to my ZNC bouncer after a network outage.  The
> echo area reads "Connecting to example.net:6697..." and "Logging in as
> `user'...", but ERC never actually reconnects, even after connectivity
> is restored.  The mode line continues to read "(ERC: CLOSED Fly/--)".

Thanks for filing this bug. From your comments on Libera, it appears
this problem has been haunting you since at least ERC 5.4 and that it
also occurs with emacs -Q. If either of those is untrue, please correct
the record. For starters, we need to find a recipe, all the way from
emacs -Q, that triggers the unwanted behavior. That way, we can dispense
with any possible complications arising from your init.el and any
third-party packages, e.g.,

> Major mode: ERC
[...]
>   erc-netsplit-mode: t
>   erc-ercn-mode: t
    ^~~~~~~~~~~~~~
>   erc-match-mode: t
>   erc-hl-nicks-mode: t
    ^~~~~~~~~~~~~~~~~
[...]
>
> Features:
> (shadow emacsbug cl-print help-fns radix-tree misearch multi-isearch
> mule-util display-line-numbers znc advice cl smiley gnus-bcklg
                                 ^~~

Also, please be as specific as possible when describing connection
parameters, whether assigned to user options or provided via entry-point
arguments to `erc-tls'. For example, if you give a keyword argument of

  :user "me@laptop/libera"

to `erc-tls', please provide something similar in the recipe, rather
than simply

  :user "$user"

And if you use auth-source, please describe the specific back end and,
if possible, the rough contents of any relevant files.

Typically, if we make it to the "Logging in as" phase, we can rule out
TLS- and process-related issues (for now) and instead focus on logical
connection parameters, such as the various `erc-session-foo' variables.
If you don't mind, please do the following before connecting for the
first time in a new -Q session:

  (require 'erc)
  (erc-toggle-debug-irc-protocol) 
  (setq erc-server-reconnect-timeout 60)
  (trace-function-background 'erc--register-connection)
  (trace-function-background 'erc-auth-source-search)
  (trace-function-background 'erc-login)
  (trace-function-background 'erc-open)
  (trace-function-background 'erc-open-network-stream)
  (trace-function-background 'erc-open-tls-stream)
  (trace-function-background 'erc-process-sentinel)
  (trace-function-background 'erc-process-sentinel-1)
  (trace-function-background 'erc-process-sentinel-2)
  (trace-function-background 'erc-schedule-reconnect)
  (trace-function-background 'erc-server-connect)
  (trace-function-background 'erc-server-reconnect)

And, after witnessing the bug, please provide the output of the
*erc-protocol* and *trace-output* buffers (out of band, if necessary,
though ideally with minimal redactions, aside from credentials) along
with the -Q recipe mentioned earlier.

Thanks again,
J.P.