executionCtx.waitUntil on write service
I have a worker that I want to call an external api on, but I want to return a response without awaiting the the external api call. (the external api call is to just save time writing to the db on another service).
however when I am testing it local and it is not hitting the service
I am using hono
https://hono.dev/api/context#executionctx
the worker is on localhost:8787 and the write service for the impression is on localhost:3000 I am able to create the impression successfully calling it directly but the waitUntil is not hitting localhost:3000 when calling the localhost:8787 endpoint
Context - Hono
Ultrafast web framework for Cloudflare Workers, Fastly Compute, Deno, Bun, Vercel, Node.js, and others. Fast, but not only fast.
9 Replies
Even without the .then() the service is not being called
Are you using miniflare or remote?
Cloudflare Docs
Known issues · Cloudflare Workers docs
Known issues and bugs to be aware of when using Workers.
The wrangler endpoint (localhost:8787) is being hit fine. I have a successful log to the console of the JSON.stringify(data)
It is not however sending the POST to the http://localhost:3000/impression
But when sending a POST in postman to http://localhost:3000/impression i get a response.
@conqr
Read the thing above
This
Even when not testing it locally and in a live environment it is not posting
Validated that the enpoint being sent is accepting traffic / getting a response in postman
there's port restrictions with live workers (flowchart by community mvp albert)
same-zone being same website in CF
what are you trying to fetch? Does it work without putting it in the ctx.waitUntil? dk if it would error out in there, iirc it would log it but not change the outcome of the request
@Chaika
It does work when removing the waitUntil:
well.. it does give a log, but when stringifying it shows an empty object. investigating
I am offloading a POST to another service to since it is not needed in the worker response.
got the request working updated the code in the message above.
Okay this is now working
working code: