---
title: "Programmatically handle long running Google Sheets tasks with Google Apps Script"
author: "Martin Hawksey"
date: 2023-02-13T10:36:22+00:00
modified: 2023-02-11T14:40:57+00:00
canonical_url: https://pulse.appsscript.info/p/2023/02/programmatically-handle-long-running-tasks-in-apps-script/
markdown_url: https://pulse.appsscript.info/p/2023/02/programmatically-handle-long-running-tasks-in-apps-script.md
categories:
  - "Intermediate"
  - "Sheets"
  - "Solutions"
tags:
  - "@choraria"
  - "script.gs"
featured_image: https://pulse.appsscript.info/files/2023/02/execution-timeout.png
description: "As noted in this post by Sourabh Choraria the Apps Script runtime limit can be a bit of a challenge. If you're encounter problems my first tip would be review your script and see what you can optimize. A common problem I often see in Google Sheets is using .getValue()/.setValue() (singular) not  .getValues()/.setValues()  (plural). If even with script optimization you are still having issues Sourabh provides a very adaptable 'design pattern' for Google Sheets. The pattern is one I can personally relate too and very similar to the approach I used in my own projects. The source post has everything you need to try this out for yourself."
---

# Programmatically handle long running Google Sheets tasks with Google Apps Script

![Programmatically handle long running Google Sheets tasks with Google Apps Script](https://pulse.appsscript.info/files/2023/02/execution-timeout.png)

 

> Image credit: Sourabh Choraria
> An approach to process hundreds of thousands of rows of data (say, on Google Sheets) without running into the script execution timeout error.
> TL;DR — the typical challenge we face with tasks that take longer to execute is that of running into the execution timeout error (that’s at 6 minutes — Script runtime — as of 10-Feb-2023) and this article … elaborates on how to bypass script execution timeout with a detailed example.

As noted in this post by Sourabh Choraria the Apps Script runtime limit can be a bit of a challenge. If you’re encounter problems my first tip would be review your script and see what you can optimize. A common problem I often see in Google Sheets is using `.getValue()`/`.setValue()` (singular) not  `.getValues()`/`.setValues()`  (plural).

If even with script optimization you are still having issues Sourabh provides a very adaptable ‘design pattern’ for Google Sheets. The pattern is one I can personally relate too and very similar to the approach I used in my own projects. The source post has everything you need to try this out for yourself.

Source: *[Programmatically handle long running tasks in Apps Script*](https://script.gs/programmatically-handle-long-running-tasks-in-apps-script/)

---

*Published by [Martin Hawksey](https://pulse.appsscript.info/p/author/admin/) on [Pulse](https://pulse.appsscript.info/). Original article: [https://pulse.appsscript.info/p/2023/02/programmatically-handle-long-running-tasks-in-apps-script/](https://pulse.appsscript.info/p/2023/02/programmatically-handle-long-running-tasks-in-apps-script/)*
