AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Intermittent Npgsql Timeout Reading From Network Stream During Connection Opening To Supabase Pooler

On .NET 8 with EF Core and Npgsql, queries intermittently fail with System.TimeoutException while reading from the network stream when opening a connection to Supabase's connection pooler (port 5432). The error is transient and retrying the request succeeds, indicating a network or pooler instability rather than a query logic issue.

highConfidence 70%Npgsql.EntityFrameworkCore.PostgreSQLConnection PoolSlow Query

Origin Analysis

The exception is raised during Npgsql's physical connection opening phase while reading startup/authentication messages from the Supabase connection pooler; the pooler or network fails to deliver data within the default Npgsql connection timeout (often 15 seconds), and Npgsql does not automatically retry transient connection establishment failures. This is a known weakness in the default Npgsql/EF Core connection strategy when dealing with unstable network links or pooler restarts.
1. Deploy a .NET 8 app using Npgsql/EF Core on Railway connected to a Supabase pooler (transaction mode port 5432). 2. Execute a typical EF Core LINQ query (e.g., paginated select) under normal traffic. 3. Observe intermittent exceptions matching the provided stack trace: System.TimeoutException during reading attempt inside NpgsqlReadBuffer.Ensure, wrapped by NpgsqlException and InvalidOperationException. 4. Resend the same request; it usually succeeds without changes.

Fixing Code Block

Edge Case Audit

Automatic retries can cause duplicate execution for non-idempotent operations (INSERT/UPDATE without unique keys) if the first attempt actually succeeded but the client timed out before receiving confirmation. Avoid using retry inside explicit transactions that rely on transaction state; if a transaction is aborted by a transient error, you must roll back manually. Increasing connection timeout may mask real network or pooler performance issues. Rollback: remove the EnableRetryOnFailure call and revert connection string timeout to the original values. Also be aware that using transaction mode (port 5432) imposes limitations: prepared statements and certain session-level features are not available; for those use session mode (6543).

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state