An explanation of implementing automatic request retry functionality in a NestJS backend application using the Axios Retry library. The lecture covers the importance of handling transient network failures, configuring retry conditions, and ensuring safe operations for idempotent HTTP methods.
Length 5:06
Captions English (Generated), Spanish (Auto-translated), French (Auto-translated), Korean (Auto-translated), Portuguese (Auto-translated), Vietnamese (Auto-translated) #nestjs #axios #retry #networking #middleware #backend #idempotency #programming
0:00 All right. So in this lecture, we're gonna start implementing our retry 0:04 functionality. Now, in HTTP networking in 0:08 general, we know that failures happen. 0:11 That is just the real world that we live in. 0:14 Systems go down, servers crash because of memory or CPU 0:18 constraints, and in general, there just might be transient 0:21 failures to an upstream server that our application is 0:25 talking to. Now, these failed requests, a lot of times we can 0:29 simply just retry, right? We know this as users of the Internet 0:33 through web browsers. When things don't work, just refresh, 0:36 and often that fixes 0:37 the issue 0:38 because we're able to send the request to a different load balance server. 0:42 There was some transient issue that is now succeeding. 0:45 And this same principle can apply to our applications, our backends. 0:49 We wanna make them resilient to these transient failures in the 0:53 upstream and be able to retry failed requests when it is 0:57 safe to do so, so that we improve the overall 1:00 stability of our application. Because as the user using it, we 1:04 don't know or care if the upstream failed one time or a few 1:08 times, and then we simply retried and then it succeeded. 1:11 We just care that our request succeeds to our app. 1:14 And so that's what we're gonna start building now is a mechanism to implement 1:18 automatic retries 1:21 for failed requests to an upstream service. 1:24 And importantly, we're gonna implement this in a safe way 1:27 so that we only 1:28 retry for network errors, and importantly, for HTTP 1:31 methods that can actually support this safely, like HTTP 1:35 GET requests. So let's go ahead and see how we do this next. 1:39 All right, so for our retry implementation, we 1:42 are gonna use 1:43 Axios Retry, which you can see here is a 1:47 third-party package from NPM that allows us to implement automatic
The rest of the transcript is for members.
Sign in