Guidelines
Explore posts from serversCDCloudflare Developers
•Created by Guidelines on 10/7/2023 in #workers-help
Worker with async Promises throws “This script will never generate a response.”
Solution
The code within the Promise was failing.
const userLogsStr = (await env.FF_EVENTLOG.get('log_' + _userId + '_' + pageIndex, 'text')) || '';
That line would firstly result in en empty string, which couldn't be parsed and cast to the type UserLogs
which is an array-type.
Because of this the code erroneously(?) errored that a response couldn't ever be generated 🙂
Changing ''
to '[]'
fixes the problem.5 replies
CDCloudflare Developers
•Created by Guidelines on 10/7/2023 in #workers-help
Worker with async Promises throws “This script will never generate a response.”
There shouldn’t be any switch case in the if-statement I’m hitting. I know that if I have a payload with 0 objects in the array then the code responds fine. If I hit the /api/userloads endpoint then that also works fine. So I’m narrowing it down to do with the Promises somehow not resolving. But I’m unsure if I can debug this with some breakpoints locally (though it likely might be possible)
5 replies