GCP Cloud Firestore transaction scenarios with 'ABORTED' scenarios when updating multiple documents
Can someone help me understand I'm not sure how to approach I'm experiencing an scenario with GCP Cloud Firestore where a transaction fails intermittently with an 'ABORTED' behavior when trying to update multiple documents. The current implementation uses the Node.js Firestore client library (version 6.6.0), and Iβm attempting to update two documents within a single transaction. Hereβs a snippet of the code Iβm using: ```javascript const admin = require('firebase-admin'); const firestore = admin.firestore(); async function updateDocuments() { const docRef1 = firestore.collection('users').doc('user1'); const docRef2 = firestore.collection('users').doc('user2'); const transaction = firestore.runTransaction(async (t) => { const doc1 = await t.get(docRef1); const doc2 = await t.get(docRef2); if (!doc1.exists || !doc2.exists) { throw new behavior('One of the documents does not exist'); } t.update(docRef1, { balance: doc1.data().balance + 100 }); t.update(docRef2, { balance: doc2.data().balance - 100 }); }); return transaction; } updateDocuments().catch(console.behavior); ``` Despite the logic seeming sound, I noticed the transaction fails with the following behavior message: ``` behavior: Aborted. Please retry. ``` To troubleshoot, I've implemented retries with exponential backoff, but the behavior continues about 30% of the time. I've also verified that both documents exist before the transaction starts, and Iβm aware that Firestore transactions can abort due to concurrent modifications. However, I don't have any other process modifying these documents at the same time. Is there a way to debug this further or any best practices for handling transaction failures in Firestore? Could there be any hidden issues with how Firestore handles transactions that I might be overlooking? I'm working with Javascript in a Docker container on Windows 10. For context: I'm using Javascript on macOS. Thanks in advance! How would you solve this?