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

Intermittent PGRST002 Schema Cache Error On Official Supabase When Querying Public Schema

Users on official Supabase experience intermittent PGRST002 errors ("Could not query the database for the schema cache") when making supabase-js queries against the public schema. The error is transient but disrupts application availability.

highConfidence 65%Supabase-JsAffected Vsupabase-Js@2.39.8

Origin Analysis

PostgREST intermittently fails to query its schema cache from the database, likely because the schema introspection connection times out or is dropped under concurrent load or during a database restart. This causes subsequent requests to return PGRST002 until the cache reload succeeds.
1. Create a Supabase project on the official platform.\n2. Use supabase-js 2.39.8 from a Node.js client.\n3. Send repeated SELECT queries to a table in the public schema.\n4. Observe intermittent errors with code PGRST002 and message \"Could not query the database for the schema cache\".\n5. The error occurs more frequently under higher concurrency or during database maintenance events.

Fixing Code Block

Edge Case Audit

Retrying may increase load on the database and PostgREST, potentially worsening connection pool exhaustion if that is the underlying cause. Use moderate retry counts and backoff. Monitor database connection counts and PostgREST logs. If the error persists after retries, fall back to a circuit breaker. Server-side fixes should be prioritized; test any configuration changes in a staging environment before rolling back to previous settings.

Ecosystem Topology