Skip to content

Commit 8c64746

Browse files
committed
fix($injector): remove INSTANTIATING entry when done.
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.
1 parent 1147f21 commit 8c64746

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/auto/injector.js

+5
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,11 @@ function createInjector(modulesToLoad) {
740740
path.unshift(serviceName);
741741
cache[serviceName] = INSTANTIATING;
742742
return cache[serviceName] = factory(serviceName);
743+
} catch (err) {
744+
if (cache[serviceName] === INSTANTIATING) {
745+
delete cache[serviceName];
746+
}
747+
throw err;
743748
} finally {
744749
path.shift();
745750
}

0 commit comments

Comments
 (0)