Same here, replacing hyperdrive with another pooler solved the issue, was really hard to pinpoint
Same here, replacing hyperdrive with another pooler solved the issue, was really hard to pinpoint
CONNECTION_CLOSEDs instead of timeouts



// Middleware to inject the database client into the context
export const database = async (c: Context, next: Next) => {
if (c.env.ENV === "test") {
const database = new MockDatabaseClient();
c.set("database", database);
await next();
} else {
const sql = postgres(c.env.HYPERDRIVE.connectionString);
const database = new KVDatabaseClient(sql);
c.set("database", database); // set the database client to the context
await next();
// clean up the client ensuring we don't kill the worker before that is completed
c.executionCtx.waitUntil(sql.end());
}
};