{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular/issues/12869","repository_url":"https://api.github.com/repos/angular/angular","labels_url":"https://api.github.com/repos/angular/angular/issues/12869/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular/issues/12869/comments","events_url":"https://api.github.com/repos/angular/angular/issues/12869/events","html_url":"https://github.com/angular/angular/issues/12869","id":189234940,"number":12869,"title":"Router 3.2.0 - Providers instantiated twice","user":{"login":"slubowsky","id":270589,"avatar_url":"https://avatars.githubusercontent.com/u/270589?v=3","gravatar_id":"","url":"https://api.github.com/users/slubowsky","html_url":"https://github.com/slubowsky","followers_url":"https://api.github.com/users/slubowsky/followers","following_url":"https://api.github.com/users/slubowsky/following{/other_user}","gists_url":"https://api.github.com/users/slubowsky/gists{/gist_id}","starred_url":"https://api.github.com/users/slubowsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slubowsky/subscriptions","organizations_url":"https://api.github.com/users/slubowsky/orgs","repos_url":"https://api.github.com/users/slubowsky/repos","events_url":"https://api.github.com/users/slubowsky/events{/privacy}","received_events_url":"https://api.github.com/users/slubowsky/received_events","type":"User","site_admin":false},"labels":[{"id":375500771,"url":"https://api.github.com/repos/angular/angular/labels/comp:%20router","name":"comp: router","color":"c7def8","default":false},{"id":130606843,"url":"https://api.github.com/repos/angular/angular/labels/type:%20bug","name":"type: bug","color":"EEEEEE","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":18,"created_at":"2016-11-14T21:44:26Z","updated_at":"2016-12-15T10:03:47Z","closed_at":null,"body":"<!--\r\nIF YOU DON'T FILL OUT THE FOLLOWING INFORMATION WE MIGHT CLOSE YOUR ISSUE WITHOUT INVESTIGATING\r\n-->\r\n\r\n**I'm submitting a ...**  (check one with \"x\")\r\n```\r\n[x] bug report => search github for a similar issue or PR before submitting\r\n[ ] feature request\r\n[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question\r\n```\r\n\r\n**Current behavior**\r\nAfter upgrading to router 3.2.0, services being provided by component module are being instantiated twice. Once while resolver is being run (last place in router is PreActivation.prototype.getToken)  and then again later during activation (last place in router is RouterOutlet.prototype.activate).\r\nUpgrading rest of Angular to 2.2.0 and leaving router at 3.1.1 it works as it used to (and looking in debugger I see service is only instantiated from PreActivation.prototype.getToken)\r\n\r\n**Expected behavior**\r\n<!-- Describe what the behavior would be without the bug. -->\r\nProviders should only be instantiated once - as they are when using router version 3.1.1\r\n\r\n**Minimal reproduction of the problem with instructions**\r\n<!--\r\nIf the current behavior is a bug or you can illustrate your feature request better with an example, \r\nplease provide the *STEPS TO REPRODUCE* and if possible a *MINIMAL DEMO* of the problem via\r\nhttps://plnkr.co or similar (you can use this template as a starting point: http://plnkr.co/edit/tpl:AvJOMERrnz94ekVua0u5).\r\n-->\r\nHaven't yet reproduced in a plnkr but my use case has a lazy loaded component that itself has sub components (not lazy loaded). The sub component has a resolver that uses a service, and the sub component itself uses the service. The service is included in the lazy loaded components module providers list and is being instantiated twice. Once apparently while router is working on resolve and once when component is being activated.\r\n\r\n**What is the motivation / use case for changing the behavior?**\r\n<!-- Describe the motivation or the concrete use case -->\r\nIts just wrong, and my service fetches data on initialization so extra instance causes extra fetch. This does not happen with router 3.1.1 (never tried 3.1.2 as deactivate guards don't work correctly in that version)\r\n\r\n**Please tell us about your environment:**\r\n<!-- Operating system, IDE, package manager, HTTP server, ... -->\r\nWindows 10, Visual Studio Code, angular-cli: 1.0.0-beta.19-3 ng serve\r\n\r\n* **Angular version:** 2.0.X\r\n<!-- Check whether this is still an issue in the most recent Angular version -->\r\n2.2.0\r\n\r\n* **Browser:** [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]\r\n<!-- All browsers where this could be reproduced -->\r\n Only tried in Chrome\r\n\r\n* **Language:** [all | TypeScript X.X | ES6/7 | ES5]\r\nTypescript 2.0.9\r\n\r\n* **Node (for AoT issues):** `node --version` =   \r\n"},"comment":{"url":"https://api.github.com/repos/angular/angular/issues/comments/267288675","html_url":"https://github.com/angular/angular/issues/12869#issuecomment-267288675","issue_url":"https://api.github.com/repos/angular/angular/issues/12869","id":267288675,"user":{"login":"michalboska","id":7025930,"avatar_url":"https://avatars.githubusercontent.com/u/7025930?v=3","gravatar_id":"","url":"https://api.github.com/users/michalboska","html_url":"https://github.com/michalboska","followers_url":"https://api.github.com/users/michalboska/followers","following_url":"https://api.github.com/users/michalboska/following{/other_user}","gists_url":"https://api.github.com/users/michalboska/gists{/gist_id}","starred_url":"https://api.github.com/users/michalboska/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michalboska/subscriptions","organizations_url":"https://api.github.com/users/michalboska/orgs","repos_url":"https://api.github.com/users/michalboska/repos","events_url":"https://api.github.com/users/michalboska/events{/privacy}","received_events_url":"https://api.github.com/users/michalboska/received_events","type":"User","site_admin":false},"created_at":"2016-12-15T10:03:47Z","updated_at":"2016-12-15T10:03:47Z","body":"@manofearth I am using 3.1.1 for the time being"}}
{"actor":{"display_login":"michalboska"}}