-
-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoiding getting stuck when failing due to uncaught exception #435
base: master
Are you sure you want to change the base?
Conversation
Can you clarify why this is needed? What exception are you seeing? At the very start (just below the PropertiesService.getUserProperties().setProperty('LastRun', new Date().getTime()); There shouldn't need to be any resetting of this property because it's just a timestamp. The script will run the next iteration when that timestamp is "too old". |
Hello @derekantrican, |
It is 6 minutes right now because that is the maximum execution time allowed by Google Apps Script: https://developers.google.com/apps-script/guides/services/quotas#current_limitations We don't usually encourage syncing calendars faster than 5 minutes (I usually even encourage 15 minutes as this is still MUCH faster than Google Calendar's current speeds of many hours), EDIT: removing my suggestion. I think I'm going to classify this PR suggestion in one of two buckets: 1) if you're getting some sort of exception, we should investigate the exception and see if we can fix it or 2) if your calendar is taking more time to sync than your As to the point of "when testing or debugging...", I think if you are frequently testing changes with the script, you can figure out how to comment out this |
Oh, I already fixed my issues. There is a branch in my fork that does some specialized work for my use-case. My primary problem was that Facebook randomly sends a reply that is HTTP 200, but does not parse as a valid ICS. In this case, the synchronization removed deleted all events from the affected calendar, which was a big problem for the service I based on the affected calendar. I did not go into this deep enough to try to log and catch what they send when it is an invalid file. I just modified the code so that invalid ICS files interrupt the sync run (since in my use-case, there is only one calendar to be synced anyway). This initially went through as an uncaught exception, for which I added specific handling in the As for commenting that code while debugging... I didn't really want to remove this check in a "live" deployment scenario, and the intermittentness of the issue + this behaviour made it a bit more annoying to sort out than I felt was necessary. No biggie though. I understand the time recommendation, and it makes sense in most cases of course. But since the original code resets the LastRun on successful completion, this feature doesn't do anything about that (nor should it, I suppose). The only thing that this try..catch does is that it makes the fail-behaviour the same as the current success-behaviour is. |
I had the same problem, with our cycling club calendar feed (strautomator.com) throwing a 500 error that was not caught by
|
If your issue persists, my customization for this is here: Sp3EdeR@5b3081b. Disclaimer, this does not handle the case when maxtries is reached, and |
When an exception propagated outside of the script, the script failed to run for a while, exiting with the message:
This avoids such a case by resetting the last run time in case of an uncaught exception