title: Firebase Firestore transactions incredibly slow (3-4 minutes)
body: <p>Edit: Removing irrelevant code to improve readability
  Edit 2: Reducing example to only uploadGameRound function and adding log output with times.</p>
  <p>I'm working on a mobile multiplayer word game and was previously using the Firebase Realtime Database with fairly snappy performance apart from the cold starts. Saving an updated game and setting stats would take at most a few seconds. Recently I made the decision to switch to using Firestore for my game data and player stats / top lists, primarily because of the more advanced queries and the automatic scaling with no need for manual sharding. Now I've got things working on Firestore, but the time it takes to save an updated game and update a number of stats is just ridiculous. I'm clocking average between 3-4 minutes before the game is updated, stats added and everything is available in the database for other clients and viewable in the web interface. I'm guessing and hoping that this is because of something I've messed up in my implementation, but the transactions all go through and there are no warnings or anything else to go on really. Looking at the cloud functions log, the total time from function call to completion log statement appears to be a bit more than a minute, but that log doesn't appear until after same the 3-4 minute wait for the data.</p>
  <p>Here's the code as it is. If someone has time to have a look and maybe spot what's wrong I'd be hugely grateful!</p>
  <p><strong>This function is called from Unity client:</strong></p>
  <pre><code>exports.uploadGameRound = functions.https.onCall((roundUploadData, response) =&gt; {
  
      console.log(&quot;UPLOADING GAME ROUND. TIME: &quot;);
      var d = new Date();
      var n = d.toLocaleTimeString();
      console.log(n);
  
      //  CODE REMOVED FOR READABILITY. JUST PREPARING SOME VARIABLES TO USE BELOW. NOTHING HEAVY, NO DATABASE TRANSACTIONS.  //
      
      
      // Get a new write batch
      const batch = firestoreDatabase.batch();
  
      // Save game info to activeGamesInfo
      var gameInfoRef = firestoreDatabase.collection('activeGamesInfo').doc(gameId);
  
          batch.set(gameInfoRef, gameInfo);
  
          // Save game data to activeGamesData
          const gameDataRef = firestoreDatabase.collection('activeGamesData').doc(gameId);
          batch.set(gameDataRef, { gameDataCompressed: updatedGameDataGzippedString });
  
  
      if (foundWord !== undefined &amp;&amp; foundWord !== null) {
  
          const wordId = foundWord.timeStamp + &quot;_&quot; + foundWord.word;
  
          // Save word to allFoundWords
          const wordRef = firestoreDatabase.collection('allFoundWords').doc(wordId);
          batch.set(wordRef, foundWord);
  
          exports.incrementNumberOfTimesWordFound(gameInfo.language, foundWord.word);
  
      }
  
      console.log(&quot;COMMITTING BATCH. TIME: &quot;);
      var d = new Date();
      var n = d.toLocaleTimeString();
      console.log(n);
  
  
      // Commit the batch
      batch.commit().then(result =&gt; {
          return gameInfoRef.update({ roundUploaded: true }).then(function (result2) {
  
  
              console.log(&quot;DONE COMMITTING BATCH. TIME: &quot;);
              var d = new Date();
              var n = d.toLocaleTimeString();
              console.log(n);
              
              return;
          });
  
      });
  
  });
  </code></pre>
  <p>Again, any help with understanding this weird behaviour massively appreciated!</p>