Skip to content

Commit

Permalink
fix($injector): remove INSTANTIATING entry when done
Browse files Browse the repository at this point in the history
getService flags services as INSTANTIATING while it calls their
provider factory, in order to detect circular dependencies. If
the service is instantiated correctly, the INSTANTIATING flag is
overwritten with the actual service. However, if the service is
not instantiated correctly, the INSTANTIATING flag should still
be removed, or all further requests for this service will be
mis-detected as a circular dependency.

Closes angular#4361
Closes angular#5577
  • Loading branch information
metamatt authored and jamesdaily committed Jan 27, 2014
1 parent 2a36b5c commit c02571e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/auto/injector.js
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,11 @@ function createInjector(modulesToLoad) {
path.unshift(serviceName);
cache[serviceName] = INSTANTIATING;
return cache[serviceName] = factory(serviceName);
} catch (err) {
if (cache[serviceName] === INSTANTIATING) {
delete cache[serviceName];
}
throw err;
} finally {
path.shift();
}
Expand Down

0 comments on commit c02571e

Please sign in to comment.