How it works...

Network hiccups can happen at any time. Where one request may not go through, the next request may go through just fine; therefore, we should have short timeouts so that we can retry the process as soon as possible, but not so short that a good request times out before it has a chance to complete normally. We must also ensure that our timeout and retry cycle has enough time to complete before the function times out. The aws-sdk is configured by default to time out after two minutes and performs three retries with an increasing delay time. Of course, two minutes is too long. Setting the timeout to 1000 (1 second) will typically be long enough for a request to complete and allow for three retries to complete before a function ...

Get JavaScript Cloud Native Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.