1

I have a script on a sheet with several editors which was working just fine a few days ago. However, it started to time-out when i tried it today. I narrowed down the problem to the function call getValue(). the code is as follows:

1 function testGetIdFromUrl() {
2    var sheet = SpreadsheetApp.getActiveSheet();
3    Logger.log(sheet);
4    var range = sheet.getRange("F6");
5    Logger.log(range);
6    var thevalue = range.getValue();
7    Logger.log(thevalue);
8 
9    Logger.log("The ID is : " + getIdFromUrl(thevalue))
10
11 }

on the logs, it shows that the last log is from line 5, where it shows 'range'; the log reads like this:

[18-07-02 12:08:38:350 HKT] Sheet
[18-07-02 12:08:38:352 HKT] Range 

The execution transcript is:

[18-07-01 23:21:26:532 PDT] Starting execution
[18-07-01 23:21:26:546 PDT] SpreadsheetApp.getActiveSheet() [0 seconds] 
[18-07-01 23:21:26:548 PDT] Logger.log([Sheet, []]) [0 seconds] 
[18-07-01 23:21:26:549 PDT] Sheet.getRange([F6]) [0 seconds]
[18-07-01 23:21:26:550 PDT] Logger.log([Range, []]) [0 seconds]
[18-07-01 23:27:36:835 PDT] Range.getValue() [370.285 seconds] 
[18-07-01 23:27:36:841 PDT] Execution failed: Exceeded maximum execution time [370.294 seconds total runtime]

When I create a copy of the same sheet and run the script, it works perfectly fine.

Similarly, if instead of running getValue() from a range on the current sheet, I reference another sheet instead, I am able to call getValue() to get values from any other sheet.

No changes were made to the permissions or any protected ranges in the sheet. Since the last time I touched it. The owner of the same spreadsheet is unable to run the script as well.

Any ideas what could be going wrong?

chuckx
  • 6,484
  • 1
  • 22
  • 23
ming
  • 11
  • 1
  • Are you getting an error message? Have you looked at the execution transcript? – chuckx Jul 02 '18 at 04:38
  • There are total 4 logs , can you please post log entry of all of those – Umair Mohammad Jul 02 '18 at 05:19
  • @chuckx There is no error message, the script just times out after 6 minutes. – ming Jul 02 '18 at 06:23
  • @Umair the script times out before the 3rd and the 4th log – ming Jul 02 '18 at 06:23
  • the execution transcript: `[18-07-01 23:21:26:532 PDT] Starting execution [18-07-01 23:21:26:546 PDT] SpreadsheetApp.getActiveSheet() [0 seconds] [18-07-01 23:21:26:548 PDT] Logger.log([Sheet, []]) [0 seconds] [18-07-01 23:21:26:549 PDT] Sheet.getRange([F6]) [0 seconds] [18-07-01 23:21:26:550 PDT] Logger.log([Range, []]) [0 seconds] [18-07-01 23:27:36:835 PDT] Range.getValue() [370.285 seconds] [18-07-01 23:27:36:841 PDT] Execution failed: Exceeded maximum execution time [370.294 seconds total runtime]` – ming Jul 02 '18 at 06:30
  • A quick google search sends you to [this SO question](https://stackoverflow.com/questions/7854573/exceeded-maximum-execution-time-in-google-apps-script) – Casper Jul 02 '18 at 07:02
  • @Casper I would think the bigger issue here is why getValue() called on a single cell containing a static string can take 370 seconds to run, after the script worked previously without issue prior to this for 2 weeks. – ming Jul 02 '18 at 08:33
  • Very much dependant on the data in your sheet. You should ask yourself what has changed since the script was working the last time. – Casper Jul 02 '18 at 08:40
  • @Casper hmm are you able to shed some light on this? I've added some unrelated tabs to the sheet, and added new participants, but i'm not sure if they would affect performance that drastically. Also, the script works in another copy of the spreadsheet with the same values and tabs, just without the collaborators – ming Jul 02 '18 at 08:57
  • Try to undo some of your changes and see if it (partially) solves your issue. There is not really one solution as the underlying issues differ a lot. – Casper Jul 02 '18 at 09:05

1 Answers1

1

The same happened with my code too. I tried reloading the sheet associated and the script. After which, I tried it with an incognito tab which then worked fine. Try reloading or opening a new browser and try it.

lalala
  • 71
  • 3