I keep getting this error:
Error: 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. (I/O type: WritableStreamSink)
This only appear when I use one drizzle connection at a time
export const db = drizzle(postgres(env.DB_URL!));
export const load: PageServerLoad = async () => {
const notes = await db
.select()
.from(tblNote)
return { notes }
};
This code works
export const db = () => {
const client = postgres(env.DB_URL!)
return drizzle(client);
}
export const load: PageServerLoad = async () => {
const notes = await db()
.select()
.from(tblNote)
return { notes }
};
But, this make request very slow because it will make new connection on every request.