You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[NOT A DRIVER BUG] Hyperdrive: "prepared statement already exists" with prepared statements #154
Through Cloudflare Hyperdrive, queries can fail with prepared statement "..." already exists (porsager#960). Cloudflare's Hyperdrive guide for postgres.js recommends prepare: true and max: 5, and warns that prepare: false can hang or fail intermittently with Hyperdrive's transaction pooling.
Plan (sub-issue of #15): once the Cloudflare edge Preview workflow (workerd-edge, PR #151) is green, bind a Hyperdrive config in front of its Neon database in previews, and add a hyperdrive scenario that runs prepare: true, max: 5 workloads repeatedly on both builds. Either it reproduces the error, which then gets a fix and a test, or about 100 clean rounds become the evidence for documenting Hyperdrive as supported. Hyperdrive is included in the Workers Free plan (100,000 queries a day).
changed the title [-]Hyperdrive: "prepared statement already exists" with prepared statements[/-][+][NOT A DRIVER BUG] Hyperdrive: "prepared statement already exists" with prepared statements[/+]on Oct 19, 2026
Not a driver bug. Hyperdrive with prepared statements works when it points at the database. It fails when it sits in front of a transaction-mode pooler such as Supabase's Supavisor on port 6543, which porsager#960 most likely used (env.DB_SUPABASE).
Evidence from the edge tier (landed in 063909d, #158). Each round runs 50 concurrent insert-and-select pairs with max: 5 and prepare: true, on both builds at compatibility dates 2025-01-01 and 2026-10-12.
Hyperdrive in front of
Result
Neon, direct
289 rounds passed in a 60-round dispatch run (39229088257), no prepared-statement error
Neon, PgBouncer pooler
passed in the same run
Supabase, direct connection, verify-full against Supabase's CA
every round passed
Supabase, Supavisor transaction mode
every round failed: prepared statement does not exist (26000), CONNECTION_CLOSED, timeouts (run 39234865111)
Supavisor's transaction mode fails the same way without Hyperdrive: locally, five connections with prepare: true give does not exist, and queued queries stall. The report's "already exists" is the other side of the same mismatch: named statements end up split across server connections by two layers of transaction pooling.
The vendors document this:
Supabase: transaction mode does not support prepared statements.
Fix: point Hyperdrive at the database itself, keep prepare: true, and use max: 5. docs/api.md (Cloudflare Workers support → Hyperdrive) now says this. CI keeps covering Hyperdrive in front of Neon direct, Neon pooled and Supabase direct on every change.
Activity
test(workerd): run prepared queries through Hyperdrive on the edge Pr…
test(workerd): run prepared queries through Hyperdrive on the edge Pr…
ci(workerd): run the scenarios on a Cloudflare edge Preview against N…
ci(workerd): run the Hyperdrive scenario against Supabase on the edge…
ci(workerd): run the Hyperdrive scenario against Supabase on the edge…
ci(workerd): run the Hyperdrive scenario against Supabase on the edge…
ci(workerd): back off on Cloudflare error pages, and run Hyperdrive a…
[-]Hyperdrive: "prepared statement already exists" with prepared statements[/-][+][NOT A DRIVER BUG] Hyperdrive: "prepared statement already exists" with prepared statements[/+]okomarov commentedon Oct 19, 2026
Not a driver bug. Hyperdrive with prepared statements works when it points at the database. It fails when it sits in front of a transaction-mode pooler such as Supabase's Supavisor on port 6543, which porsager#960 most likely used (
env.DB_SUPABASE).Evidence from the edge tier (landed in 063909d, #158). Each round runs 50 concurrent insert-and-select pairs with
max: 5andprepare: true, on both builds at compatibility dates 2025-01-01 and 2026-10-12.prepared statement does not exist(26000),CONNECTION_CLOSED, timeouts (run 39234865111)Supavisor's transaction mode fails the same way without Hyperdrive: locally, five connections with
prepare: truegivedoes not exist, and queued queries stall. The report's "already exists" is the other side of the same mismatch: named statements end up split across server connections by two layers of transaction pooling.The vendors document this:
prepare: falseis discouraged behind Hyperdrive.Fix: point Hyperdrive at the database itself, keep
prepare: true, and usemax: 5.docs/api.md(Cloudflare Workers support → Hyperdrive) now says this. CI keeps covering Hyperdrive in front of Neon direct, Neon pooled and Supabase direct on every change.