serverless: Error in cloudflare workers : Uncaught (in response) Error: The script will never generate a response
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)
}
}
I have found the following page but it does not mention any solution "The script will never generate a response” on CloudFlare Workers | Zuplo Docs
Following code still getting the error.
await client.connect()
/*
const {
rows: [{ now }]
} = await client.query('select now();')
ctx.waitUntil(client.end())
*/
return new Response('eeee')
After comment out
await client.connect()
the code starting to run
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 17
@ben-xD That worked. Thanks 👍 . I don’t see that error anymore.