How to send an early response and continue executing #3163
Unanswered
gregoryforel
asked this question in
Q&A
Replies: 2 comments 2 replies
-
Hi @gregoryforel. If you use Cloudflare Workers, can use c.executionCtx.waitUntil((async () => {
// This code is executed after the server has respond
})())
return c.json(
// ^ You have to add `return`
{
status: 'In progress',
data: { backupId },
},
HttpStatusCode.Accepted
); If you don't, probably you can use like that: ;(async () => {
// Describe the subsequent processing in this code
})()
return c.json(
// ^ You have to add `return`
{
status: 'In progress',
data: { backupId },
},
HttpStatusCode.Accepted
); |
Beta Was this translation helpful? Give feedback.
1 reply
-
So, I'm not using Cloudflare Workers, and unfortunately, the other async solution does not work. I solved the issue using |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am migrating a Google Cloud function to a Bun/Hono backend. My function currently allows me an early response and continue to proceed with the rest of the code.
Google Cloud function:
In Hono, I tried to simply use
c.json
without returning the statement, but it doesn't work:Beta Was this translation helpful? Give feedback.
All reactions