• Nick Stenning's avatar
    Only make one request for features data at once · 726ecc0b
    Nick Stenning authored
    This was a fun bug. If multiple feature checks are done in rapid
    succession when the features cache is empty (such as, for example,
    during the first digest cycle at application boot time) then the
    features client would keep kicking off HTTP requests until the first one
    returned.
    
    This would clearly be a misfeature, but wouldn't actually have caused
    any problems but for the fact that the spinner in
    `h/directives/simple-search.coffee` does this to determine whether to
    spin:
    
        scope.$watch (-> $http.pendingRequests.length), (pending) ->
          scope.loading = (pending > 0)
    
    This means that kicking off dozens of requests at a time keeps
    invalidating the digest cycle (because the value of
    `$http.pendingRequests.length` keeps changing), so it never ends. The
    result is the ever-horrible `infdig` (infinite digest cycle) error from
    Angular: https://docs.angularjs.org/error/$rootScope/infdig.
    726ecc0b
features.js 2.26 KB