Book Image

JavaScript at Scale

By : Adam Boduch
Book Image

JavaScript at Scale

By: Adam Boduch

Overview of this book

Have you ever come up against an application that felt like it was built on sand? Maybe you've been tasked with creating an application that needs to last longer than a year before a complete re-write? If so, JavaScript at Scale is your missing documentation for maintaining scalable architectures. There's no prerequisite framework knowledge required for this book, however, most concepts presented throughout are adaptations of components found in frameworks such as Backbone, AngularJS, or Ember. All code examples are presented using ECMAScript 6 syntax, to make sure your applications are ready for next generation browsers.
Table of Contents (12 chapters)
11
Index

Failure recovery


In the preceding section, we started to think about fault tolerance in our frontend code. That is, our application needs to survive the loss of a failed component—at least in the short term. But what if there are certain kinds of errors that we can recover from? So instead of shutting down the component after detecting the error, we would take some alternative course of action; one that would still satisfy the user.

In this section, we'll look at the various ways our components can recover from failed operations. For example, we can retry an operation, or we could flush out the bad state of a component by restarting it. Sometimes, it makes sense to get input from the user on how they wish to proceed during a recovery effort.

Retrying failed operations

If our component executes an operation that fails, it can retry the operation. The operation doesn't even have to be an integral part of the component. But since the component depends on this operation, if it fails, then so does...