Hi~
I want to use Netlify Functions to handle Slack commands but these functions will need to perform database read and write and will most likely end up exceeding the Slack 3000ms limit to give an answer (which trigger an operation_timout
on the Slack side).
So in order to do so I need to send Slack an empty 200 before ending the function process which in pratice look like this:
exports.handler = async (event, context) => {
performHeavyOperationAsynchronously(); // database read write and such
// don't wait for previous function to end and just fire the 200 answer
return { statusCode: 200, body: "" }; // send empty 200
}
So while this code run nicely in development (using netlify dev
) when in production on Netlify it appears to not launch / keep processing what’s inside performHeavyOperationAsynchronously()
(because perhaps there’s some sort of a process.exit()
after the handler return answer)
Any idea how to fix that ? (or if this is even possible?) / what’s the cause of the process not keeping processing the async function after function return?
Thanks~!