Common failure modes
- Timeout: Scripts have a maximum execution time. Long loops or slow API calls can exceed it.
- Quota limits: Daily triggers, email sends and API calls are subject to quotas.
- Duplicate triggers: A trigger can fire twice if not idempotent, creating duplicate records or emails.
- Silent errors: A
try/catchthat swallows an error without logging leaves no trace. - Partial runs: A script that writes to a sheet and then fails before sending a notification leaves inconsistent state.
Design for visible failure
Log the start and end of each run, record the input and the outcome, and send a failure notification to a monitored address. A successful run should be distinguishable from a partial run. Store a status column in the sheet so operators can see what completed.
Make runs idempotent where possible
Use a unique identifier for each record and check whether it has already been processed before writing or sending. This prevents duplicate actions when a trigger fires twice.
Provide a recovery path
Document how to pause triggers, how to re-run a failed batch and how to correct partial state. A runbook is part of the deliverable, not an afterthought.
Test at the point where the real system runs
A script that works in the editor may fail when triggered by a form submission because of permissions, quota or timing. Test with real triggers in the target environment.
Design each run as a recoverable transaction
Apps Script automations often cross several boundaries: a form event starts the run, a spreadsheet is read, a record is created and an email is sent. A failure between any two steps can leave partial state. Add a stable record identifier and a status field such as queued, processing, completed or needs-review. Before repeating a run, check that identifier and the last successful step so retries do not create duplicate rows or send duplicate notifications.
Use locks when multiple executions could update the same data. Keep critical sections small, and avoid holding a lock while making slow external requests. When a service call fails, log the step, a safe error summary and a correlation ID; do not store passwords, tokens or unnecessary personal information in logs. A caught exception should either be handled intentionally or rethrown after it has been recorded.
Separate transient failures from data problems
A timeout, rate limit or temporary service error may succeed on retry. Invalid input, missing authorization or a wrong destination will not. Use bounded retries with increasing delay for transient failures, and send persistent or non-retryable problems into an explicit review path. Infinite retries hide incidents and can consume quotas while making the original problem harder to diagnose.
Quotas and execution limits vary by account and service and can change. Check current Apps Script documentation before relying on a specific limit, then design headroom into the workflow. Batch spreadsheet reads and writes where possible, and avoid one remote request per cell. For high-volume or latency-sensitive workloads, compare Apps Script with a managed service or custom integration rather than forcing every process into a lightweight script.
Write the recovery runbook before go-live
The runbook should say where the execution log lives, who receives failure alerts, how to pause triggers, how to identify a partially completed batch, how to correct its state and how to safely resume. Test by intentionally removing a permission, using a malformed record or forcing a controlled staging error. Confirm that the operator sees the failure and can recover without asking the original author what to do.
Make the workflow idempotent wherever practical, but document steps that cannot be repeated safely. The lead intake flow applies the same distinction between saving a record and delivering its notification. The Automation Discovery Worksheet can help capture these failure paths before implementation.
Frequently asked questions
How do I debug a triggered script?
Add logging to a sheet or use Stackdriver logging. Record the trigger event object and the state before and after the action.
Can I avoid quotas by splitting the work?
Yes, batch processing with time-based triggers can stay within quotas, but the workflow must handle partial completion and recovery.
Explore the related Pen Beam service → · Read approved client feedback
FIELD NOTES / DISCUSSION
Join the conversation.
Share a question, useful experience, or a thoughtful correction. Comments are moderated before publication.
No comments yet. Start the discussion with a useful question or observation.