While using Cloud Functions, we've encountered the following error:
Timestamp: 2023-10-21 18:50:18.281 EEST Function: v8-specialist
---updateUserByID finish update---
Caused by: Error
at WriteBatch.commit (/workspace/node_modules/firebase-admin/node_modules/@google-cloud/firestore/build/src/write-batch.js:433:23)
at DocumentReference.update (/workspace/node_modules/firebase-admin/node_modules/@google-cloud/firestore/build/src/reference.js:433:14)
at Object.updateUserByID (/workspace/dist/src/DB/db.js:74:14)
at createSpecialistOrderListService (/workspace/dist/src/crud/specialist/services/specialistList/createSpecialistOrderListService.js:38:29)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async getRecommendedSpecialistsListController (/workspace/dist/src/crud/specialist/controllers/getRecommendedSpecialistsListController.js:25:44)
at async /workspace/dist/src/framework/express/middlewares/express-handler.js:18:36
Error Details:
- Code: `13`
- Description: `Received RST_STREAM with code 1`
- Metadata: `{ internalRepr: Map(0) {}, options: {} }`
- Note: `Exception occurred in retry method that was not classified as transient`
This error seems to pop up when we execute the following command in our update function:
const writeResult = await admin
.firestore()
.collection(FirestoreCollections.Users)
.doc(userID)
.update(fieldsToUpdate);
Example of fieldsToUpdate
:
[
{
"boolean": true,
"number": 100,
"id": "some_id"
}
]
However, what's puzzling is that this method seems to work flawlessly in our other cloud functions. In certain situations, even if an error is thrown during the update, the data in Firestore might still get updated.
- The issue persists even when tested locally.
- Upon creating a new cloud function with the same method, everything operates smoothly.
functions .region('europe-west1').pubsub.schedule('every 1 hours').(...)
– Ladanum