Skip to content

fix(cadente): rebuild listener on fatal accept errors#47

Merged
CypherPotato merged 1 commit into
mainfrom
codex/github-mention-listener-fails-to-recover-from-connection-lo
May 29, 2026
Merged

fix(cadente): rebuild listener on fatal accept errors#47
CypherPotato merged 1 commit into
mainfrom
codex/github-mention-listener-fails-to-recover-from-connection-lo

Conversation

@CypherPotato

Copy link
Copy Markdown
Member

Motivation

  • The listener can become permanently invalid after a network interface reset (observed on Android) and the accept loop keeps retrying the same broken socket instead of recovering.
  • Synchronous AcceptAsync failures (and unexpected ObjectDisposedException) should be treated like fatal async accept errors so the listener can be rebuilt.

Description

  • Treat synchronous accept failures by inspecting SocketException.SocketErrorCode in StartAccept and trigger the same listener rebuild path used for fatal accept completions via TriggerListenerRebuild when appropriate.
  • Add a recovery path for ObjectDisposedException during AcceptAsync that triggers a rebuild while the host is still listening and not already restarting.
  • Harden TriggerListenerRebuild so it no-ops when the host is stopped or disposed and keep the single-flight rebuild guard using _listenerRestarting.
  • Implement RebuildListenerAsync to dispose the old listener, create a replacement listener with retry delays, dispose partially-created replacement sockets on failure, and restart all accept slots when rebuild succeeds.

Testing

  • git diff --check ran with no reported whitespace/errors.
  • dotnet build cadente/Sisk.Cadente/Sisk.Cadente.csproj -c Release succeeded and produced build artifacts and NuGet packages (build emitted SourceLink warnings because the repository has no remote).

Codex Task

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant