With database: "pg", the generated prod void/db caches its pg.Pool in module scope and reuses it across requests. That doesn't work on workerd: a TCP socket belongs to the request that opened it and is dead by the next one, so any query after the first in a warm isolate hangs and Cloudflare kills the request with:
1101 — "The Workers runtime canceled this request because it detected that your Worker's code had hung and would never generate a response."
In practice every DB-backed route 500s in prod as soon as the isolate warms up. no-DB routes are fine; the first request after a cold start works, everything after it hangs.
The generated module (void/dist/index.mjs, the dialect === "postgresql" template):
let_prodInstance;functiongetInstance(){if(getRuntimeBinding("DATABASE_URL")){// local dev: fresh pool per chain, because workerd kills sockets between requestsreturndrizzle(newpg.Pool({connectionString: getRuntimeBinding("DATABASE_URL"),max: 1}),{ schema });}// prod (Hyperdrive): cached across requests_prodInstance??=drizzle(getConnectionString(),{ schema });return_prodInstance;}The local branch comment already mentions the problem ("workerd kills TCP sockets between requests, so pg.Pool's cached connections go stale and hang").
Fix is to drop the cache and do what the local branch does:
functiongetInstance(){returndrizzle(newpg.Pool({connectionString: getConnectionString(),max: 1}),{ schema });}Hyperdrive pools on the origin side anyway, so a fresh pool per chain is cheap. We're running this as a pnpm patch against void@0.9.2 and it fixes the outage.
Env:void@0.9.2, database: "pg" over Hyperdrive, deployed to Cloudflare Workers.
With
database: "pg", the generated prodvoid/dbcaches itspg.Poolin module scope and reuses it across requests. That doesn't work on workerd: a TCP socket belongs to the request that opened it and is dead by the next one, so any query after the first in a warm isolate hangs and Cloudflare kills the request with:In practice every DB-backed route 500s in prod as soon as the isolate warms up. no-DB routes are fine; the first request after a cold start works, everything after it hangs.
The generated module (
void/dist/index.mjs, thedialect === "postgresql"template):The local branch comment already mentions the problem ("workerd kills TCP sockets between requests, so pg.Pool's cached connections go stale and hang").
Fix is to drop the cache and do what the local branch does:
Hyperdrive pools on the origin side anyway, so a fresh pool per chain is cheap. We're running this as a
pnpmpatch againstvoid@0.9.2and it fixes the outage.Env:
void@0.9.2,database: "pg"over Hyperdrive, deployed to Cloudflare Workers.