We are using fresh service APIs to read and create assets using request template in the serverless app. When the number of API calls exceeds the rate limit, we get hit with 429 error and the error has a useful header retry-after.
The problem is that the serverless app does not support setTimeout (setTimeout in servless app) and because of that we are not able to wait for the time specified and retry after the wait period. Is there any explicit way to wait for the delay and retry so that the rate limit is satisfied?
Hi @Puspalatha_B1,
The Request Method retryDelay option is not a solution for rate limits as it only supports up to 1500 milliseconds. It’s helpful when the API server errors out temporarily and immediately succeeds upon retry due to other issues.
The serverless execution cannot be delayed with timeout since the server will be kept alive and occupied during the waiting time and other apps cannot use this space. For fair use, any timeout or delay methods within the serverless app are limited.
Scheduled events is a better option to postpone actions after some time. It supports postponing function a minimum of 5 minutes away from the current time. Please refer to the documentation and use it when considering everything.
If the app cannot wait for 5 minutes, you can implement the logic from where the API calls are made (if not the serverless function) to wait for a minute and call the API again.