Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Apps Script disables recurring time-based trigger

I have been trying to create a Google Apps Script which sets a trigger before time-out and continues after a set period of time.

The first trigger works properly, but the second trigger always fails to execute the code, with this error message "This trigger has been disabled for an unknown reason."

I stripped back the code to test this with the following:

function setTriggerTest() {

  var triggers = ScriptApp.getProjectTriggers();

  for ( var i in triggers ) {

     //delete all previous triggers for this function

     if (triggers[i].getHandlerFunction() == "setTriggerTest") {
     ScriptApp.deleteTrigger(triggers[i])
     
     }
  }

  
  var currTime = (new Date()).getTime(); 

  //set a new trigger to launch this function in 10000 milliseconds 
  ScriptApp.newTrigger("setTriggerTest")
               .timeBased()
               .at(new Date(currTime+10000))
               .create();

  
}

This code runs, then successfully sets up the next trigger, then runs the setTriggerTest() function again, then sets up another trigger. But then that second trigger fails to execute setTriggerTest(), with the error message "This trigger has been disabled for an unknown reason."

Is there any reason behind this and/or workaround? Basically I want to perform functions that take 15 minutes altogether so it needs to be split over three executions.

like image 202
fungiblecommodity Avatar asked Oct 26 '25 10:10

fungiblecommodity


1 Answers

This is a known issue and has been reported multiple times in the issue tracker. Consider adding a star(on top left) to these issues to let Google know you want them to prioritize the issue. For some, Reverting back to old rhino engine has resolved the issue.

Issues:

  • https://issuetracker.google.com/issues/150756612
  • https://issuetracker.google.com/issues/142490621
  • https://issuetracker.google.com/issues/142405165
  • https://issuetracker.google.com/issues/149668305

Related questions:

  • Why does time-based GAS Trigger get disabled for unknown reason in V8?
  • Triggers are being disabled unexpectedly with "account for the owner of this trigger has been disabled" message
  • GAS triggers randomly disabling after being created programmatically
  • Time driven triggered script producing error/Disabled last run error
like image 67
TheMaster Avatar answered Oct 29 '25 09:10

TheMaster



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!