Apps Script: Too many simultaneous invocations: Spreadsheets
Last verified
Exception: Too many simultaneous invocations: SpreadsheetsWhat it means
This exception means too many executions were calling the same service, typically the Spreadsheet service, at the same time. It is a concurrency limit, separate from daily quotas and from the 6-minute runtime limit.
Google's quotas page lists 30 simultaneous executions per user and 1,000 per script. In practice the Spreadsheets variant shows up intermittently on triggered scripts, form-submit handlers and web apps when several runs overlap and all read or write the same spreadsheet.
Nothing is wrong with the code's logic; the same function succeeds when it runs alone. The fix is to stop overlapping runs from colliding.
What it looks like
function onFormSubmit(e) {
const lock = LockService.getScriptLock();
lock.waitLock(30000);
try {
SpreadsheetApp.getActive().getSheetByName('Log').appendRow(e.values);
} finally {
lock.releaseLock();
}
}Why it happens
- Multiple form submissions or webhook calls arriving together, each starting its own execution.
- A web app (doGet or doPost) receiving bursts of requests.
- Overlapping time-driven triggers when a run takes longer than the trigger interval.
- Custom functions in many cells calling SpreadsheetApp at once.
How to fix it
- Serialize access with LockService: call getScriptLock().waitLock(30000) before touching the sheet and releaseLock() after.
- Catch the exception and retry with exponential backoff instead of failing the whole run.
- Reduce the number of calls per execution by batching reads and writes.
- Make sure time-driven runs finish well within their interval so they cannot overlap.
- For web apps receiving bursts, write incoming items to a queue (a sheet or properties) and process them in one scheduled run.
How to stop it recurring
Any handler that can be triggered concurrently should take a script lock before writing shared data. Keep the locked section short, and process bursts asynchronously from a queue. Note that waitLock throws if it cannot get the lock in time, so handle that case too.
Official documentation: developers.google.com/apps-script/guides/services/quotas. See all Apps Script error messages or the Apps Script limits and quotas.
Related errors
- Too many scripts running simultaneously for this Google user accountThere are too many scripts running simultaneously for this Google user account.
- Service Spreadsheets timed out while accessing documentException: Service Spreadsheets timed out while accessing document with id…
- Service invoked too many times in a short timeException: Service invoked too many times in a short time: Calendar. Try…
Definitions
- Google Apps ScriptGoogle Apps Script is Google's cloud-hosted JavaScript platform for automating Google Workspace: Sheets, Gmail
- Error HandlingError handling is the practice of anticipating, detecting, and responding to errors in software execution, inc
- Rate LimitingRate limiting is a technique that controls the number of requests a client can make to a server within a given
- OAuth 2.0OAuth 2.0 is the IETF authorization standard (RFC 6749) that lets an app access your account in another servic
Quick answers
What does "Too many simultaneous invocations: Spreadsheets" mean in Apps Script?
This exception means too many executions were calling the same service, typically the Spreadsheet service, at the same time. It is a concurrency limit, separate from daily quotas and from the 6-minute runtime limit. Google's quotas page lists 30 simultaneous executions per user and 1,000 per script.
How do I fix "Too many simultaneous invocations: Spreadsheets"?
1. Serialize access with LockService: call getScriptLock().waitLock(30000) before touching the sheet and releaseLock() after. 2. Catch the exception and retry with exponential backoff instead of failing the whole run. 3. Reduce the number of calls per execution by batching reads and writes. 4. Make sure time-driven runs finish well within their interval so they cannot overlap. 5. For web apps receiving bursts, write incoming items to a queue (a sheet or properties) and process them in one scheduled run.
Run the job somewhere with its own limits
If a script keeps hitting its host's quotas, an Autonoly workflow can run the same steps on a schedule in an isolated cloud container, and the AI agent has a terminal with Python for steps that need code. Autonoly has limits of its own, priced in credits.
Also see Agent terminal & SSH.