Function launch twice

322 views
Skip to first unread message

Anthony Ciceron

unread,
Jan 15, 2022, 1:02:20 PM1/15/22
to Google Apps Script Community
Hi everyone !

I have a problem : sometimes, my function is launch two times :(

So : i have one function with an execution time of 15 sec.

Sometimes, 12 sec after the start, this function restart...

I'm not sure but it seems to do it when i have a "flush" in my function.

There is someone who have this probleme ? Have you a solution ?

Thanks everyone !


CBMServices Web

unread,
Jan 15, 2022, 1:10:52 PM1/15/22
to google-apps-sc...@googlegroups.com
Have seen form submission triggers launch twice usually within the same second. Added lock checks on the functions to prevent that from happening. 

How is your function triggered?


--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/21145e88-af4a-4b5b-b624-5a3dc9bf19c4n%40googlegroups.com.

Anthony Ciceron

unread,
Jan 15, 2022, 1:11:52 PM1/15/22
to Google Apps Script Community
Sorry but it seems that it's don't due to my flush action...

It do it with another function wich don't contain a flush line.

I forgot to say that it didn't do it before some days, and i don't change anything on my script (just a few lines)...



Anthony Ciceron

unread,
Jan 16, 2022, 5:17:37 AM1/16/22
to Google Apps Script Community
Thank you George ! I'll check it out :)

It's a form submission :

<form method="POST" action="<?= url_script; ?>" id="creationPlanningForm" onsubmit="return click_valid_planning(this)">

Something strange it that didn't do that before. It do that thing about 4-5 days.

Also it s not launch twice within the same second but when the function is finished...



CBMServices Web

unread,
Jan 16, 2022, 1:04:27 PM1/16/22
to google-apps-sc...@googlegroups.com
Interesting, have not seen that type of failure myself. In that case, a lock might not help you. You may need to add a flag somewhere and check it to see if the function has already run and if so, to abort the second run.

Its a lot of work especially if you have a lot of forms to take care of, but there is little else you can do as far as I know.

Anthony Ciceron

unread,
Jan 16, 2022, 4:19:33 PM1/16/22
to Google Apps Script Community
Thank you George :)

I'll try to add a flag as you said. Like a status in my database..

If i find any solution i'll share it here !!!

Thanks again for your time :)

Laurie Nason

unread,
Jan 17, 2022, 1:13:59 AM1/17/22
to google-apps-sc...@googlegroups.com
I had this once before and eventually realised that I had an "onEdit" function named "onEdit" that I had set up as an installable trigger - so it was running twice. Once as a regular trigger, and once as the installable. 
Not sure if this helps any in your situation.
Laurie

Anthony Ciceron

unread,
Jan 17, 2022, 2:27:29 AM1/17/22
to Google Apps Script Community
Thanks Laurie !

I'll try to change my function names and tell you if it resolve my problem !
Reply all
Reply to author
Forward
0 new messages