postgres
postgres copied to clipboard
Fails with `Error: The script will never generate a response.` on cloudflare pages
This is similar to #865, however unlike in that issue I create the postgres client on each request and still get following error on cloudflare pages with "compatibility_flags": ["nodejs_compat"]
✘ [ERROR] A hanging Promise was canceled. This happens when the worker runtime is waiting for a Promise from JavaScript to resolve, but has detected that the Promise cannot possibly ever resolve because all code and events related to the Promise's I/O context have already finished.
[wrangler:inf] GET /api/test 500 Internal Server Error (8ms)
✘ [ERROR] Uncaught (in response) Error: The script will never generate a response.
Using it as follows
app.get("/api/test", async (c) => {
console.log("test route");
const sql = postgres(c.env.DATABASE_URL);
const users = await sql`
select *
from users`;
// users = Result [{ name: "Walter", age: 80 }, { name: 'Murray', age: 68 }, ...]
return c.json(users);
});