Hello all,
I submitted a support request for this but I guess that’s not the right channel for these questions so trying here. If anyone can answer any of these it would be greatly appreciated.
copy/paste of my original ticket begins here (I should note this is all in the context of custom apps only for our tenant, not deployed to the marketplace):
I have a few questions regarding using the FDK to create custom serverless apps.
Reference:
https://developers.freshworks.com/docs/app-sdk/v2.3/freshservice/serverless-apps/
- From doc: “The serverless apps are run in the sandbox mode. Therefore, usage of methods such as process, buffer, clearImmediate, clearInterval, clearTimeout, setImmediate, setInterval, and setTimeout in the app logic is not supported.”
setTimeout is a common method to create a blocking “pause” in the program flow, with that not being available, is there a feature in the framework I’m not finding to be able to introduce a “pause”? We need to detect rate limits, such as with your “request” api which will return a 429 code in the error object when exceeded. In this case, the app logic needs to pause, and retry. How then do we pause? (I’ve created and tested a “time” based approach but it’s really not a good way to simply pause, as it wastes cpu cycles). Does the framework provide another mechanism to handle this common need? We must detect a rate limit, pause, and retry. Is there no pause, but rather we are supposed to use the schedule feature and schedule a retry of the function x seconds in the future maybe?
1a. The “request” api throws an exception when the limit is breached and includes the 429 code in the error object, however the headers are empty, there is no “Retry-After” value as there is if you were to call the freshservice api directly. Why is this not included in the error thrown by “request”, it does have the “headers” field in the object, but it’s empty.
Reference:
https://developers.freshworks.com/docs/app-sdk/v2.3/freshservice/serverless-apps/product-events/
- From doc: “The default app execution timeout is 20 seconds. If the request timeout is increased to 20, 25, or 30 seconds, the app execution timeout is extended to 40 seconds.”
How exactly do I make this change? I want to increase the app execution timeout to 40 seconds.
2a. What exactly happens when this timeout is reached? How can I know when this happens?
Reference:
https://developers.freshworks.com/docs/app-sdk/v2.3/freshservice/smi-apps/
- From doc: “The rate limit for the serverless component is 50 triggers per minute.”
This is from the smi-apps section of the docs, however I assume it applies to all serverless apps. Please let me know if that’s not the case. So what exactly happens on the 51st trigger? How can I know when this happens? Can it be increased?
Really hoping for some answers so I can make some final design decisions. Assuming I can increase my execution timeout to 40 seconds my biggest “potential” blocker may be the 50 trigger per minute limit on the serverless function. I don’t think we would be hitting that limit under normal circumstances but there could be other bulk/automated things that happen by others that could spike it, so I need to plan/design for that possibility.