15

Can I use something like die() (in php) at my Apps Script application? I googled this question, the most acceptable solution is to throw new Error, but in this case I don't want to receive notification about script crash (as I not the only one who receives them).

I just want to terminate the script.

ZygD
  • 22,092
  • 39
  • 79
  • 102
Nikage
  • 578
  • 2
  • 7
  • 18
  • While this isn't quite a duplicate, any answer that answers this question for Javascript will typically answer it for GAS, as GAS primarily uses Javascript. A good place to start is: http://stackoverflow.com/questions/9298839/is-it-possible-to-stop-javascript-execution, but if you just want the script to stop, you can also just 'return' nothing. – HDCerberus Dec 22 '14 at 12:53
  • I believe the user was asking how to stop a Google Apps script once it has started running (for instance, if they accidentally kicked off a function that had an infinite loop), not how to make the function end when they were writing it. – Jon Senchyna Jun 07 '16 at 13:56
  • Possible duplicate of [How to stop a google app script from an infinite loop always executed when opening the Google Spreadsheet document?](http://stackoverflow.com/questions/14892906/how-to-stop-a-google-app-script-from-an-infinite-loop-always-executed-when-openi) – Jon Senchyna Jun 07 '16 at 14:06
  • @sandwich Thank you for correcting me. My understanding of php is limited and I did not take the time to look up what `die()` actually does. I have retracted my vote to close this as a duplicate. – Jon Senchyna Jun 08 '16 at 12:36

1 Answers1

11

If you are in the code editor, and want to stop a script from running, you can click the "cancel" link in the toast display.

Or you can click "View" -> "Executions" from the code editor and then terminate the script.

You can also go directly to your executions at the link:

https://script.google.com/home/executions

Terminate Execution

Alan Wells
  • 30,746
  • 15
  • 104
  • 152
  • What do you do when **terminate** is grayed out. Status is **paused**. I have alerts showing in my infinite loop. I am using the alerts because the logs in executions are taking hours to show up. I guess I just have to wait for it to time out but there should be some better way – aNewb Nov 20 '20 at 02:55
  • It might be worth creating an issue on the Issue Tracker. The link is: [https://issuetracker.google.com/](https://issuetracker.google.com/) Or click the "Feedback" link in the bottom left of the Executions navigation bar. Those are really the only two way to make Google aware of the problem. – Alan Wells Nov 20 '20 at 14:05
  • Tried to but Create button stayed gray even though I included Component: Executions Termination option, Title : Executions Termination option should be available when script is paused and a description. ??? – aNewb Nov 22 '20 at 17:57
  • If you are trying to create a new issue on the Issue Tracker, make sure that you're logged into a Google account, and choose the category: `Public Trackers > Google Workspace Developers > Apps Script` – Alan Wells Nov 22 '20 at 18:29
  • 173906140 terminate paused script – aNewb Nov 22 '20 at 20:36
  • Sorry, but I can't help you create a new issue on the Issue Tracker. I suggest that you join the Apps Script group at: [https://groups.google.com/g/google-apps-script-community](https://groups.google.com/g/google-apps-script-community) and explain your situation there. – Alan Wells Nov 22 '20 at 23:19