Continue execution after WP REST API response
I am trying to extend the WordPress REST API with an endpoint that takes Zoom webhooks. Zoom requires a response within 3 seconds or will blacklist your endpoint address, but the processing that I want to do when I receive a webhook takes longer than 3 seconds.
What options do I have for returning a response from the WP REST API immediately but then carrying on execution?
exec()a child process in the background then return the response (but this might be a security risk)
- Write a flag to the filesystem then return the response. A regular
cronjob will spot the flag and do the processing (but this will result in a delay in the process being done depending on how frequently the
cronjob is scheduled)
For non-WP scenarios I’ve seen solutions proposed that use
fastcgi_finish_request() but I’m not sure how I could
return a result from my callback function using this.