Skip to content

fix(redis): connect has no timeout, leaks the socket after a failed AUTH, and is not single-flight #1307

Closed

Description

@ZhuchkaTriplesix

Problem

lib/core/database/redis_connection.dart (_openConnection, ~lines 142-210):

  1. No timeout. _conn.connect(host, port) and SecureSocket.connect(...) have no timeout, unlike PostgreSQL / MySQL (10 s). A host that drops packets keeps the spinner and Test Connection busy for the OS TCP timeout (about two minutes).
  2. Leaked socket. When AUTH or PING throws, the catch sets _conn = null and _command = null without closing the connection. disconnect() closes only if (c != null && wasConnected). Every failed attempt, including each Test Connection with a wrong password, leaves an open socket.
  3. No single-flight. PostgreSQL and MySQL made connect() single-flight (two callers opened two sockets and two SSH tunnels). Redis still allows two concurrent _openConnections: the second overwrites _conn, the first socket and its tunnel handle are leaked.

Scope

  • Add a connect timeout (10 s, configurable like the others) to plain and TLS connects.
  • Close the connection in the failure path.
  • Single-flight connect() as in PostgresConnection.connect.
  • Tests with a fake server / injected connector: timeout, close after AUTH failure, one attempt for two callers.

Acceptance

  • An unreachable host fails after the timeout with a timed out message.
  • A failed AUTH closes the socket.
  • Two concurrent connect() calls open one connection and one tunnel.

Activity

  1. added
    bugSomething isn't working
    stabilityTheme parser epic label: stability
    connectionsDatabase connections, URI parsing, pools
    P2Medium priority / Parity & Refactoring
    on Oct 10, 2026
  2. ZhuchkaTriplesix commented on Oct 10, 2026

    @ZhuchkaTriplesix
    MemberAuthor

    Сделано в #1319, смержено в dev.

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

Metadata

Metadata

Labels

P2Medium priority / Parity & RefactoringbugSomething isn't workingconnectionsDatabase connections, URI parsing, poolsstabilityTheme parser epic label: stability

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions