Post method not working with Queues on CF Worker
Hono version: 4.6.20
Wrangler version: 3.107.2
I've tried a lot but fetch function inside queue is not executing in the worker both deployed version and local dev server.
17 Replies
hey! can you add syntax highlighting please?
also, can you share the relevant bits of your wrangler?
Here's my wrangler.json
thanks!
full disclosure, i have limited experience w cloudflare
fetch function with post method is not working inside queue
some of what you've got going on w
Context
doesn't totally make sense to me tho
i think the place to start is by losing the any
typingany suggestion on improving this?
i'm maybe a little extreme, but i only ever use
any
in generics
and when possible/relevant, i use unknown
instead
so i'd start by:
- always using c
to stand for Context
- always passing c
as the first arg, if you're passing at all
- typing as Context
, if at all
(#2 you can ease up on with time, but it's a good initial mental model, imo
does that scan?
when you use any
, you essentially break typescript, and it's on you to fix it. these suggestions are meant to give us a clear picture of what your code is actually doingunderstood, but I used
unknown
first, then used any to see if that makes any differenceso this is a case where you definitely don't want to use either
unknown
or any
c
should always extend type Context
why were you using any
/unknown
to begin w?updated codes
still not working
this too?
queue(batch: MessageBatch<QueueDataType>, c: Env)
are you getting an error message?no, I'm not getting any errors
oh, i see, my bad. that's the
queue
fn signature
in that case, queueHandler
needs to take Env
, not c
/Context
what's not working then?fetch operations in queue handler
ah, gotcha
so what's happening?
nothing, it just stucks
so the request gets made, but the promise never resolves?
or what?
i'm happy to help you try and troubleshoot, but i'll need more info