Skip to content

fix(redis): connect timeout, no socket left after a failed AUTH, single-flight connect (#1307) - #1319

Merged
ZhuchkaTriplesix merged 2 commits into
devfrom
fix/1307-redis-connect
Oct 10, 2026
Merged

ZhuchkaTriplesix merged 2 commits into
devfrom
fix/1307-redis-connect

Conversation

@ZhuchkaTriplesix

Copy link
Copy Markdown
Member

Closes #1307

Problem (redis_connection.dart)

  1. The connect had no timeout, unlike PostgreSQL and MySQL (10 s): a host that drops packets held the caller and Test Connection for the OS TCP timeout.
  2. When AUTH or PING threw, the failure path only cleared _conn / _command; the socket stayed open, and disconnect() closes only if (wasConnected). Each failed attempt (each Test Connection with a wrong password) left a socket.
  3. connect() was not single-flight: two concurrent callers opened two sockets and two SSH tunnels, and the second overwrote the first's connection.

Fix

  • The socket is opened by Socket.connect / SecureSocket.connect with connectTimeout (default 10 s, a constructor parameter), then handed to the client with connectWithSocket (already what the TLS path did). AUTH + PING run under the same timeout.
  • The failure path destroys the socket it opened.
  • connect() shares an in-flight attempt, as in PostgresConnection / MysqlConnection.

Tests (redis_connect_lifecycle_test.dart, with a small RESP server): a wrong password is an authentication failure and the server sees the socket closed; a server that accepts and never answers fails with a timeout error and is closed; two concurrent connects open one connection; a failed attempt can be retried.

…le-flight connect (#1307)

- The TCP and TLS connect take a timeout (10 s, as PostgreSQL and MySQL),
  and so does AUTH / PING, so an unresponsive host no longer holds the
  caller for the OS timeout.
- A failed attempt closes its socket; before, every wrong password left
  one open.
- Concurrent connect() calls share one attempt: one socket, one tunnel.
@github-actions github-actions Bot added bug Something isn't working stability Theme parser epic label: stability connections Database connections, URI parsing, pools P2 Medium priority / Parity & Refactoring labels Oct 10, 2026
…mer (#1307)

Socket.connect with a timeout creates a timer; widget tests that open a
Redis view and end with the connect pending failed on it. The default
limit is a test seam (zero: no limit) set by flutter_test_config; tests
of the limit pass their own.
@ZhuchkaTriplesix
ZhuchkaTriplesix merged commit a01bbd4 into dev Oct 10, 2026
15 checks passed
@ZhuchkaTriplesix
ZhuchkaTriplesix deleted the fix/1307-redis-connect branch October 11, 2026 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working connections Database connections, URI parsing, pools P2 Medium priority / Parity & Refactoring stability Theme parser epic label: stability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant