porsager / postgres

Postgres.js - The Fastest full featured PostgreSQL client for Node.js, Deno, Bun and CloudFlare
The Unlicense
7.03k stars 255 forks source link

Cloudflare: I/O Error #884

Closed zhihengGet closed 3 days ago

zhihengGet commented 1 month ago

Hi guys, i have been getting

Cannot perform I/O on behalf of a different request. I/O objects (such as streams, request/response bodies, and others) created in the context of one request handler cannot be accessed from a different request's handler. This is a limitation of Cloudflare Workers which allows us to improve overall performance."

how do u avoid this ? i have idle_timeout to zero, max_timeout to default, i create a new instance in sveltekit hook.server.ts

i feel like locals.sql=postgres( ) does not really create new instance

zhihengGet commented 3 days ago

figured out, i initialized sql instance too early by the time , it was garbage collectioned