title: How to ensure concurrency of http Cloud Function invocations to only one at a time
body: <p>I've setup an Http Cloud Function as backend for a reservation system. This function accesses data from Cloud Firestore retrieving existing time of reservation and to check if the reservation has overlaps from the existing times. This would be no problem if only one concurrent instance of the request can be triggered, however I've noticed that when requesting to the same function from multiple sources at the same time, the function would run those multiple request in a somewhat parallel way based on my log.</p>
  
  <p>Here is a snippet of my function below:</p>
  
  <pre><code>exports = module.exports = functions.https.onCall(async (data, context) =&gt; {
    const { stand_id, user_id, reservation } = data;
    const isReservationValid = await checkAvailability(reservation, stand_id);
  
    if (!isReservationValid) {
      throw new functions.https.HttpsError('aborted', 'Errr');
    }
  
    return await createReservation(stand_id, user_id, reservation);
  });
  </code></pre>
  
  <p>The problem arises if I call this function and pass in the same stand_id, and overlapping reservation times, I've noticed that the function wouldn't wait for the whichever is the first function to get invoked to finish before starting the subsequent requests.</p>
  
  <p>Is there a way I can solve this problem better? Or any workaround?
  Or did I just misunderstood the documentation below?:
  <a href="https://i.stack.imgur.com/VWgDK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VWgDK.png" alt="Doc screenshot"></a></p>