I have the following webhook, and it is listening for a payment provider API to update the status of an order once it is 'paid'. In logs for Firebase Functions, I get the console log Payment status paid meaning that I get the update of the order correctly. However, when I try to call the function responsible for updating Firestore, I get the following:
@firebase/firestore: Firestore (7.16.0): Connection GRPC stream error. Code: 13 Message: 13 INTERNAL: Received RST_STREAM with code 2
exports.webhooks = functions.https.onRequest(function (req, res) {
mollieClient.payments
.get(req.body.id)
.then((payment) => {
console.log("Payment status " + payment.status);
if (payment.isPaid()) {
updateOrderStatusPaid(req.body.id);
return null;
}
return null;
})
.catch((error) => {
res.send(error);
});
console.log("Request body " + req.body);
});
function updateOrderStatusPaid(orderId) {
firebase
.firestore()
.collection("orders")
.where("paymentId", "==", orderId)
.update({
status: payment.status
})
.then(function () {
console.log("Success");
return null;
})
.catch(function (error) {
console.log("Error " + error);
});
}
Here is my package.json file
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"lint": "eslint .",
"serve": "firebase emulators:start --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "8"
},
"dependencies": {
"@mollie/api-client": "^3.2.4",
"axios": "^0.20.0",
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"firebase": "^7.16.0",
"firebase-admin": "^8.10.0",
"firebase-functions": "^3.6.1",
"grpc": "^1.24.4"
},
"devDependencies": {
"eslint": "^5.12.0",
"eslint-plugin-promise": "^4.0.1",
"firebase-functions-test": "^0.2.0"
},
"private": true
}
I cannot find anything specific to this problem. I am already using Firestore on my server side so there is no problem with initialization of Firebase. Maybe somebody knows where the problem might be or suggest something I should do to solve this. Thank you!
The closest link to this problem is https://github.com/googleapis/nodejs-datastore/issues/679 where still there is not answer.