How to avoid cancel from client disconnection?

I’m trying to build a serverless chatbot for lark. Lark is an IM app like WhatApp. When someone sends a message to the bot account, it will send a POST request to an URL. I’m using worker as an intermediary to send the message to ChatGPT, and then send another POST request to send the reply to the chat. This should be two separate actions, but I’m currently putting the second into the first one to make them one worker. However, since the call of ChatGPT can take some time to response, lark may close the connection, and kills everything. Can I ask if it’s possible to return a response to make lark happy, and then run everything in background? Or is it possible to use two workers in RPC? Thank you!
2 Replies
akazwz
akazwz6mo ago
wait until can run every thing background.
zyc
zycOP6mo ago
When the client disconnects, all tasks associated with that client’s request are proactively canceled. If the Worker passed a promise to event.waitUntil(), cancellation will be delayed until the promise has completed or until an additional 30 seconds have elapsed, whichever happens first. thank you! Also, is it possible for it to run a bit longer? event.waitUnti can only holds for 30 seconds
Want results from more Discord servers?
Add your server