Is this a Worker/Wrangler/Hyperdrive bug? Request succeeds but then errors on refresh

I have a weird situation whereby an endpoint hosted on CF Workers successfully returns a response. But if I hit refresh soon after (within a couple of seconds) I then get a CF 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.
✘ [ERROR] Uncaught (in response) Error: The script will never generate a response.
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.
The error makes no sense to me because if the promise could not "possible ever resolve", then it wouldn't have given me a 200 status with output the first time. The problem is only on refresh. This happens only with endpoints that talk to Hyperdrive. A simple endpoint that outputs a static response does not exhibit this problem, not matter how many times, or how quick, I hit refresh. I'm using Itty Router, and I cannot see anything in my code that would point to a hanging promise or anything like that - I'm using Itty as advertised. Thank you.
3 Replies
DaniFoldi
DaniFoldi12mo ago
do you happen to reuse the client that you create using hyperdrive between requests? That's my first guess, since it specifically mentions that it will only be valid during the request where you get the credentials
Mitya
MityaOP12mo ago
PurpleBlob, you're a genius. I was indeed doing that. I've been adapting my app from Express use, and handling DB pools manually, so I hadn't properly adapted this part. Thank you!
DaniFoldi
DaniFoldi12mo ago
happy to help MeowHeartCloudflare
Want results from more Discord servers?
Add your server