Skip to content
Advertisement

Google App Script randomly stop executing

I have a script that basically take info from a website for multiple users, and put these info in a google spreadsheet, with one sheet per users.

I have a function that remove values of the firstline, resize every columns, and put back the setValues:

function adjustColumnsAndIgnoreFirstLine(sheet) {
  Logger.log('--- Adjust columns ---')
  const range = sheet.getRange("1:1")

  // save the title line
  const datas = range.getValues();
  // clear it
  range.clearContent();

  // format without the title lines
  var lastColumn = sheet.getLastColumn()
  sheet.autoResizeColumns(1, lastColumn);

  // set width to a minimum
  for (var i = 1; i < 37; i++) { // fixed number of columns
    if (sheet.getColumnWidth(i) < 30) {
      sheet.setColumnWidth(i, 30);
    }
  }

  // put back titles
  range.setValues(datas);
}

my problem is that the script stop executing in the middle of the function. I still have the “execution please wait” popup, but in the logs, the script stopped like there was no error (execution finished) with this as the last log: last log

And, on the google spreadsheet:

spreadsheet

One thing to note is that the problem doesn’t comes from the script itself, as I do not encounter this problem on any of my machines, but my client does. My client ran the script on different navigator (chrome and edge), and had the same problem, but on different users (sometimes it blocks at the before-last user, sometimes at the before-before-last user…)

So I’m kinda lost on this problem…

Advertisement

Answer

The problem is actually a timeout. Google app script limit the execution time of a script at ~6 minutes.

There is existing issues for this

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement