Skip to content

feat(connection): auto-reconnect after a dropped WebSocket #64

Description

@albedosehen

SurrealConnectionManager caches the Surreal connection and reuses it for
every operation. If the underlying WebSocket drops — e.g. the SurrealDB server
is restarted (docker compose up -d, a pod restart) — the manager has no way
to detect the transport-level disconnect: isConnected stays true, and
getConnection() keeps handing back the dead connection. Every subsequent
query then fails until the host process itself is restarted.

ConnectionRetryConfig / ExtendedConnectionConfig already exist in
src/connection/config.ts but are not wired into the connection manager.

Proposed

  • Classify transport-level disconnect errors (WebSocket close / "no close
    frame received or sent") distinctly from query errors.
  • On a transport disconnect, redial under a per-connection lock so concurrent
    failed callers coalesce onto a single reconnect, then retry the failed
    operation once.
  • Non-transport errors (bad SQL, schema violations, timeouts) still surface
    immediately — no retry.

Deferred from v1.4.0: that release is scoped to v3 correctness fixes;
auto-reconnect is a separate resilience feature and is tracked here.

Activity

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