From 8c64746f67a3d1aba5d4f5caade5f645033e666c Mon Sep 17 00:00:00 2001 From: Matt Ginzton Date: Mon, 30 Dec 2013 16:02:32 -0800 Subject: [PATCH] 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 #4361. --- src/auto/injector.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/auto/injector.js b/src/auto/injector.js index 4d4b1b93bbbb..a04ff1e6124f 100644 --- a/src/auto/injector.js +++ b/src/auto/injector.js @@ -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(); }