Handle fetchQueue error for preempted requests

When a particular instance preempts a request round trip, the fetch queue can
be left in an indeterminate state that can cause future requests to error out
due to assumptions about the fetch queue’s contents.

This change ensures that the fetchQueue is completely cleaned. Additionally it
protects from NPEs that might occur due to preempted requests in promise
supporting environments.
If the reset queue option is used then the fetchQueue object will be reset.


On Mon, Jun 9, 2014 at 12:17 PM, Roman Bataev <notifications@github.com>
wrote:

> In src/loading.js:
>
> > @@ -398,6 +399,11 @@ function fetchQueue(options, $super) {
> >        var index = _.indexOf(fetchQueue, this);
> >        if (index >= 0) {
> >          fetchQueue.splice(index, 1);
> > +
> > +        // If we are the last of the fetchQueue entries, invalidate the queue.
> > +        if (!fetchQueue.length && fetchQueue === self.fetchQueue) {
>
> When is fetchQueue !== self.fetchQueue?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/walmartlabs/thorax/pull/373/files#r13552358>.
>