extended-salmon•2y ago
Functions: Script Execution Timeout
I keep getting this error about 5-10% of the time which is an issue since this function is used for all chat loads.
The timeout occurs after ~1s. (avg script time is 250-400ms)
I have outer and inner try catches for the entire script. Sometimes I do "catch" it and it goes down the error path with clear error explanations in the stack trace.
But most of the time it just gives me this message at the bottom. And I cannot catch it with my error logging, so what could the issue be since it works 90-95% of the time?
Is there something you guys could potentially do to allow the script timeout (which occurs straight away as mentioned above) to be caught anyways?
[
{
"type":"debug",
"payload":{
"message":"[ERROR]: Encountered an error in a Function step. Error: Script execution timed out."
}
}
]
25 Replies
You need to look if there is a response error. Use: fetchResponseVar.ok and then throw an error with the fetchResponseVar.status and fetchResponseVar.message.
extended-salmonOP•2y ago
Yeah tried that just now, still happening. You think there's a limit do the amount of data that can be processed? Most of it is just populating variables and creating strings based on booleans.
Also tried the api call for at a rate above 1 per second to test it out - did that literally for 3 minutes in a row. No issues there.
rare-sapphire•2y ago
Same issue here
extended-salmonOP•2y ago
how long is your script? and how fast does your execution timeout appear?
rare-sapphire•2y ago
Its literally a function to calculate Today’s date. That error only happens to me within the first test, if I do a second try it works normally.
extended-salmonOP•2y ago
yeah seems like the same thing is happening to me, but sometimes it comes back even after a few tries. and in the functions editor it happens prob at a rate of 3-10%.
have you tried it in production?
rare-sapphire•2y ago
Yep same here. Not yet in production
extended-salmonOP•2y ago
Yeah I'll see tmrw how it handles production, I was gonna break my code down into multiple functions to see if that helps but if yours is a "today's date" it might have to to with the fact that it's the first function - because my other ones have never timed out.
and I chain 3 of them in the beginning of the flow
rare-sapphire•2y ago
Yes, it’s the first one and also almost at the beginning of the flow.
extended-salmonOP•2y ago
sigh, and just when I said that I got a itmeout in a function thats in the very middle of the flow
we are having no issues. are you sure you are passing / catching the correct errors?
fascinating-indigo•2y ago
is this similar to my issue?
Yes
@NiKo | Voiceflow @bamelement @Daniel
extended-salmonOP•2y ago
CONTEXT FOR VF TEAM
- Timeout is the 1s version that appears straight away, inner and outer try catches are applied yet they error is not caught.
- Timeout has appeared with baserow.io, gsx2json (with & w/o API) and apps script. (When trying with apps script there is no error message in the execution logs on their end after a VF error).
- When intensively testing the api limits they're never reached, I really do not think any of the APIs are the issue behind. Also have never had an issue with the APIs on previous projects or flows when they were in standard API block format.
- Script has been working 80-95% of the time. Error occurs more often in the Designer rather than the Functions editor.
- 99% of the exec timeout happened for the function ID listed below, only one exec timeout for another function. The function listed is the first function of the flow.
- Project ID: 65a854c509ee4247d039ae99
- Function ID: 65a76b7ed92f42b0660da051
- Workspace: 29kMYMepko
rare-sapphire•2y ago
This is kind of what I see out of some tries. Mine is just a calculate Today's date function. First one fails, the others work. https://www.loom.com/share/daf093039b0243cebdd2f0bf23d420f7?sid=62f87ec6-c0c4-4601-9482-12c2d0e25557
Can you send me the function? I DMed you.
@Adam [Astro System] flagged w the team & DM-ing you!
rare-sapphire•2y ago
@Adam [Astro System] please update me if you have any news
Some quick updates:
It seems that the timeout issue with some Functions during cold start is linked to the use of
.toLocaleString
We are still investigating but in the meantime you might want to restructure your code to avoid using it.
We are also going to update our doc to reflect that.extended-salmonOP•2y ago
Thank you Niko. Fyi I have not used that in my functions.
extended-salmonOP•2y ago
I did however try creating a brand new project (instead of importing a .vf file I only imported the function) and did two tests so far - yesterday and just now. This however did not work for another VF user 🤔


Not sure I fully get it. Are you confirming you are not facing any timeout issue anymore on your end?
extended-salmonOP•2y ago
So previously when trying the timeout issue on new projects I would export an existing vf project and import into a new project --> that led to the timeout issue remaining in the new project.
Yesterday I created a blank project and imported only the function --> this led to no timeout issues for me at least.
Then asked @nicofrank1 to try the same thing as me by creating a blank project but he still experienced the same timeout issues as previously.
I have done quite a lot of testing today and for me there hasn't been any issues thus far. But once again - for @nicofrank1 he still experienced the same thing.
Not sure if this will help with your error elimination process but this is what we found yesterday ^
Additional context is that my project with execution timeout had another bug where the "Unable to render assistant" popup would appear all the time. So seemingly that entire project was buggy.
---
To answer yor question - yes, but only on completely new projects that are not imported from existing vf files.
I will let you guys know if it does happen again for me though.
rare-sapphire•2y ago
It seems this was the issue in my case. It appears to be working now. I'm going to test it throughout the day, and check if i get it again. Thanks for the response.
We are still working on optimizing Functions. A fix should be pushed to solve the Date / toLocalString issue.