saito200
CDCloudflare Developers
•Created by saito200 on 6/8/2024 in #workers-help
Return ok status immediately on async process or not?
My use case:
- A webhook intercepts request from telegram bot
- Request message is sent to openai and response awaited
- Response is sent to Telegram bot with Telegram API
- Request returns a 200 response
I am using Holo
the issue here seems to be that if the 200 response seems to take a while, telegram can retry the request, entering into a never ending loop potentially and pinging openai several times with the same question
I think maybe an option is to immediately send a 200 response and then await for openai response (the response is sent to telegram via telegram API, not in the response)
However I'm not sure that is okay with Holo or workers (looks like Holo needs to return a response)
I.e.
- app.post (from telegram)
- retrieve user message
- send 200 response
- send message to OpenAI API
- wait for OpenAI response
- Send OpenAI response to Telegram API
- return
I don't think this will work
I'm not really a backender, what is the correct way to do this?
4 replies