Intermittent CONNECT_TIMEOUT errors that persist for minutes

Hello,

I am deploying a React Router v7 SSR app to AWS App Runner and running into issues.

Environment:
  • Supabase Pro plan, tried both Session mode (5432) and Transaction mode (6543)
  • AWS App Runner (1 instance, low traffic)
  • Drizzle ORM + postgres-js (porsager/postgres)
  • React Router v7 SSR appProblem:Getting DrizzleQueryError: write CONNECT_TIMEOUT on simple user queries. The key issue is that once it starts failing, retries don't help for several minutes. This happens somewhat randomly, even with low traffic.Error example:DrizzleQueryError: Failed query: select ... from"users" where "id" = $1 limit $2Error: write CONNECT_TIMEOUTWhat I've tried:
  • Session mode (port 5432) - same issue
  • Transaction mode (port 6543) - same issue
  • Retry logic with exponential backoff - doesn't help because the entire connection pool seems "stuck"Current postgres-js config:const client = postgres(process.env.DATABASE_URL!,{ max: 10, prepare: false, connect_timeout: 15, idle_timeout: 20, max_lifetime: 120, keep_alive: 30,});
Any ideas on what it could be? I've tried different postgres configurations, AppRunner max_concurrency settings, etc
Was this page helpful?