title: Why getting “Resource has been exhausted” although the usage is within the quota limit?
body: <h2>The problem</h2>
  <p>I'm using Google Sheets API v4 from node.js (Cloud Functions for Firebase) via <code>googleapis</code> npm package to write to the Google Sheets.</p>
  <p>Getting this error sporadically:</p>
  <pre><code>Error: Resource has been exhausted (e.g. check quota).
      at Gaxios._request (/workspace/node_modules/gaxios/build/src/gaxios.js:89:23)
      at process._tickCallback (internal/process/next_tick.js:68:7)
  </code></pre>
  <p>It doesn’t say which particular quota is reached, though.</p>
  <p>At that particular moment, indeed, there were many concurrent function executions that write to the Google Sheets, and several of them failed:
  <a href="https://i.stack.imgur.com/oFHp4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oFHp4.png" alt="Failed executions" /></a></p>
  <h2>GCP console</h2>
  <p><a href="https://console.cloud.google.com/iam-admin/quotas" rel="nofollow noreferrer">https://console.cloud.google.com/iam-admin/quotas</a> says that the quota statuses are fine:
  <a href="https://i.stack.imgur.com/0kK4Z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0kK4Z.png" alt="Quotas" /></a></p>
  <p><a href="https://console.cloud.google.com/apis/api/sheets.googleapis.com/quotas" rel="nofollow noreferrer">https://console.cloud.google.com/apis/api/sheets.googleapis.com/quotas</a> shows that the usage at the moment of issue is within the quota limits:
  <a href="https://i.stack.imgur.com/jTjlt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jTjlt.png" alt="Read requests per 100 sec" /></a>
  <a href="https://i.stack.imgur.com/dPbzA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dPbzA.png" alt="Write requests per 100 sec" /></a></p>
  <h2>The guess</h2>
  <p>I'm suspecting that I may reach the “Write requests per 100 seconds <strong>per user</strong>” quota limit… because the “traffic by response code” chart shows 2.03 reqs/sec, which gives 203 requests per 100 seconds, and all of them from one credential:
  <a href="https://i.stack.imgur.com/wIEIL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wIEIL.png" alt="Traffic" /></a></p>
  <p>However “Per-user quota usage is not displayed”, and neither error message or GCP console give definite indication on what is the actual quota being exhausted.</p>
  <p>Also, there is a counter-argument to this guess: <strong>total</strong> “requests per 100 seconds” in the chart above is below 100, and I presume that “requests per 100 seconds <strong>per user</strong>” cannot be higher than total.</p>
  <h2>The questions</h2>
  <ol>
  <li>Is my conclusion based on the charts in the GCP console correct that I’m not reaching the quota limits?</li>
  <li>How to figure out which quota limit is referred to in the error message?</li>
  <li>What other cause can be there behind <code>Resource has been exhausted (e.g. check quota)</code> error?</li>
  </ol>
  <hr />
  <h2>Update based on the comment</h2>
  <p>Here are the links to the actual code repository.</p>
  <ul>
  <li>The cloud function that is triggered: the <a href="https://github.com/PureBhaktiArchive/audioseva/blob/master/functions/src/TrackEditing/TE.functions.ts#L216" rel="nofollow noreferrer">line that calls my repository class method</a>.</li>
  <li>The <a href="https://github.com/PureBhaktiArchive/audioseva/blob/25d1a50214173f5fa23454bf19e85a648ba8cd85/functions/src/AbstractRepository.ts#L106" rel="nofollow noreferrer">repository method itself</a> that calls the <code>Spreadsheet</code> class method to update the rows.</li>
  <li>The <a href="https://github.com/PureBhaktiArchive/audioseva/blob/25d1a50214173f5fa23454bf19e85a648ba8cd85/functions/src/Spreadsheet.ts#L386" rel="nofollow noreferrer">Spreadsheet method</a> which prepares data for updating/appending.</li>
  <li>Actual <a href="https://github.com/PureBhaktiArchive/audioseva/blob/25d1a50214173f5fa23454bf19e85a648ba8cd85/functions/src/Spreadsheet.ts#L347" rel="nofollow noreferrer">method that calls the <code>googleapis</code></a>.</li>
  </ul>
  <p>This is not a <a href="https://stackoverflow.com/help/minimal-reproducible-example">Minimal, Reproducible Example</a>, this is the actual code used. I don't think providing a reproducible example is worth time in this case, because the question is primarily related to interpreting the error message and figuring out which particular quota limit has been reached.</p>