Hi I'm getting the following error in Cloudflare workers
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. ✘ [ERROR] Uncaught (in response) Error: The script will never generate a response.
My code is simple
import { Client } from '@neondatabase/serverless'
import { Env } from './models'
export default {
async fetch(request: Request, env: Env, ctx: ExecutionContext) {
const client = new Client({/*details*/})
await client.connect()
const {
rows: [{ now }]
} = await client.query('select now();')
ctx.waitUntil(client.end())
return new Response(now)
}
}
About the problem, I have found the following page but it does not mention any solution https://zuplo.com/blog/the-script-will-never-generate-a-response-on-cloudflare-workers/
There is no unreturned code here so I'm not supposed to see this error
neondatabase/serverless
library matter. Does it share promises between clients, like described in that blog post? Or maybe it has a bug where it's legitimately hanging? It looks like someone (you?) opened an issue there which seems like the right next step. – Tijuanatike@neondatabase/serverless
package. I suspect the problem is coming from there. – Robert