I am using a google cloud function as a webhook to receive a payload from a 3rd party service. Typically when such services make requests to webhooks they expect a HTTP 200 as acknowledgement. However with a cloud function setup as below (and as recommended by google) the requesting service is returned a 408 when ongoing processing is happening.
In this situation the 3rd party service (in this case its cloudmailin but the same applies for any webhook I have attempted to integrate with) will retry the request even though it has been handled successfully.
My question is: how can I get the cloud function to return a 200 and still continue the async processing?
//This will return a 408 even though the request is processed successfully
exports.emailIngest = functions.https.onRequest((request, response) =>
{
//return the promise from the firestore admin SDK as per google docs
return admin.auth().getUserByEmail(request.body.envelope.from).then((user) => {
console.log('Successfully fetched user data:', user.toJSON());
}).catch(function (error) {
console.log('Error fetching user data:', error);
});
});