<p dir="auto"><strong>I'm submitting a ...</strong>  (check one with "x")</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[X] bug report =&gt; search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request =&gt; Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question"><pre class="notranslate"><code class="notranslate">[X] bug report =&gt; search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request =&gt; Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
</code></pre></div>
<p dir="auto"><strong>Current behavior</strong><br>
After upgrading working app from 4.0.0 to 4.0.1 or 4.1.0-beta.0, when navigating to a new component (lazy loaded but dont know if that matters yet) CanDeactivate guard is called with null component and providers are not being provided to new component (sometimes I get only one of these errors, sometimes I get both as shown below, and occasionally I get other errors not captured here)</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ERROR Error: Uncaught (in promise): Error: No provider for MyService!
Error
    at injectionError (core.es5.js:1231) [angular]
    at noProviderError (core.es5.js:1269) [angular]
    at ReflectiveInjector_._throwOrNull (core.es5.js:2770) [angular]
    at ReflectiveInjector_._getByKeyDefault (core.es5.js:2809) [angular]
    at ReflectiveInjector_._getByKey (core.es5.js:2741) [angular]
    at ReflectiveInjector_.get (core.es5.js:2610) [angular]
    at AppModuleInjector.NgModuleInjector.get (core.es5.js:3557) [angular]
    at MySearchModuleInjector.NgModuleInjector.get (core.es5.js:3557) [angular]
    at resolveDep (core.es5.js:10930) [angular]
    at createClass (core.es5.js:10799) [angular]
    at createDirectiveInstance (core.es5.js:10627) [angular]
    at createViewNodes (core.es5.js:11977) [angular]
    at createRootView (core.es5.js:11882) [angular]
    at callWithDebugContext (core.es5.js:13013) [angular]
    at injectionError (core.es5.js:1231) [angular]
    at noProviderError (core.es5.js:1269) [angular]
    at ReflectiveInjector_._throwOrNull (core.es5.js:2770) [angular]
    at ReflectiveInjector_._getByKeyDefault (core.es5.js:2809) [angular]
    at ReflectiveInjector_._getByKey (core.es5.js:2741) [angular]
    at ReflectiveInjector_.get (core.es5.js:2610) [angular]
    at AppModuleInjector.NgModuleInjector.get (core.es5.js:3557) [angular]
    at MySearchModuleInjector.NgModuleInjector.get (core.es5.js:3557) [angular]
    at resolveDep (core.es5.js:10930) [angular]
    at createClass (core.es5.js:10799) [angular]
    at createDirectiveInstance (core.es5.js:10627) [angular]
    at createViewNodes (core.es5.js:11977) [angular]
    at createRootView (core.es5.js:11882) [angular]
    at callWithDebugContext (core.es5.js:13013) [angular]
    at resolvePromise (zone.js:712) [angular]
    at resolvePromise (zone.js:683) [angular]
    at :4200/polyfills.bundle.js:2764:17 [angular]
    at Object.onInvokeTask (core.es5.js:4116) [angular]
    at ZoneDelegate.webpackJsonp.626.ZoneDelegate.invokeTask (zone.js:397) [angular]
    at Zone.webpackJsonp.626.Zone.runTask (zone.js:165) [&lt;root&gt; =&gt; angular]
    at drainMicroTaskQueue (zone.js:593) [&lt;root&gt;]
    at HTMLAnchorElement.ZoneTask.invoke (zone.js:464) [&lt;root&gt;]
defaultErrorLogger @ core.es5.js:1084
ErrorHandler.handleError @ core.es5.js:1144
next @ core.es5.js:4754
schedulerFn @ core.es5.js:3828
SafeSubscriber.__tryOrUnsub @ Subscriber.js:234
SafeSubscriber.next @ Subscriber.js:183
Subscriber._next @ Subscriber.js:125
Subscriber.next @ Subscriber.js:89
Subject.next @ Subject.js:55
EventEmitter.emit @ core.es5.js:3814
NgZone.triggerError @ core.es5.js:4185
onHandleError @ core.es5.js:4146
webpackJsonp.626.ZoneDelegate.handleError @ zone.js:369
webpackJsonp.626.Zone.runGuarded @ zone.js:141
_loop_1 @ zone.js:604
drainMicroTaskQueue @ zone.js:613
ZoneTask.invoke @ zone.js:464
core.es5.js:1084 

ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'canDeactivate' of null
TypeError: Cannot read property 'canDeactivate' of null
    at CanDeactivateGuard.webpackJsonp.224.CanDeactivateGuard.canDeactivate (CanDeactivate.ts:9)
    at MergeMapSubscriber.project (router.es5.js:4394)
    at MergeMapSubscriber._tryNext (mergeMap.js:120)
    at MergeMapSubscriber._next (mergeMap.js:110)
    at MergeMapSubscriber.Subscriber.next (Subscriber.js:89)
    at ArrayObservable._subscribe (ArrayObservable.js:114)
    at ArrayObservable.Observable._trySubscribe (Observable.js:57)
    at ArrayObservable.Observable.subscribe (Observable.js:45)
    at MergeMapOperator.call (mergeMap.js:85)
    at Observable.subscribe (Observable.js:42)
    at EveryOperator.call (every.js:33)
    at Observable.subscribe (Observable.js:42)
    at Object.subscribeToResult (subscribeToResult.js:22)
    at MergeMapSubscriber._innerSub (mergeMap.js:130)
    at MergeMapSubscriber._tryNext (mergeMap.js:127)
    at CanDeactivateGuard.webpackJsonp.224.CanDeactivateGuard.canDeactivate (CanDeactivate.ts:9)
    at MergeMapSubscriber.project (router.es5.js:4394)
    at MergeMapSubscriber._tryNext (mergeMap.js:120)
    at MergeMapSubscriber._next (mergeMap.js:110)
    at MergeMapSubscriber.Subscriber.next (Subscriber.js:89)
    at ArrayObservable._subscribe (ArrayObservable.js:114)
    at ArrayObservable.Observable._trySubscribe (Observable.js:57)
    at ArrayObservable.Observable.subscribe (Observable.js:45)
    at MergeMapOperator.call (mergeMap.js:85)
    at Observable.subscribe (Observable.js:42)
    at EveryOperator.call (every.js:33)
    at Observable.subscribe (Observable.js:42)
    at Object.subscribeToResult (subscribeToResult.js:22)
    at MergeMapSubscriber._innerSub (mergeMap.js:130)
    at MergeMapSubscriber._tryNext (mergeMap.js:127)
    at resolvePromise (zone.js:712) [angular]
    at resolvePromise (zone.js:683) [angular]
    at :4200/polyfills.bundle.js:2764:17 [angular]
    at Object.onInvokeTask (core.es5.js:4116) [angular]
    at ZoneDelegate.webpackJsonp.626.ZoneDelegate.invokeTask (zone.js:397) [angular]
    at Zone.webpackJsonp.626.Zone.runTask (zone.js:165) [&lt;root&gt; =&gt; angular]
    at drainMicroTaskQueue (zone.js:593) [&lt;root&gt;]
    at HTMLAnchorElement.ZoneTask.invoke (zone.js:464) [&lt;root&gt;]"><pre class="notranslate"><code class="notranslate">ERROR Error: Uncaught (in promise): Error: No provider for MyService!
Error
    at injectionError (core.es5.js:1231) [angular]
    at noProviderError (core.es5.js:1269) [angular]
    at ReflectiveInjector_._throwOrNull (core.es5.js:2770) [angular]
    at ReflectiveInjector_._getByKeyDefault (core.es5.js:2809) [angular]
    at ReflectiveInjector_._getByKey (core.es5.js:2741) [angular]
    at ReflectiveInjector_.get (core.es5.js:2610) [angular]
    at AppModuleInjector.NgModuleInjector.get (core.es5.js:3557) [angular]
    at MySearchModuleInjector.NgModuleInjector.get (core.es5.js:3557) [angular]
    at resolveDep (core.es5.js:10930) [angular]
    at createClass (core.es5.js:10799) [angular]
    at createDirectiveInstance (core.es5.js:10627) [angular]
    at createViewNodes (core.es5.js:11977) [angular]
    at createRootView (core.es5.js:11882) [angular]
    at callWithDebugContext (core.es5.js:13013) [angular]
    at injectionError (core.es5.js:1231) [angular]
    at noProviderError (core.es5.js:1269) [angular]
    at ReflectiveInjector_._throwOrNull (core.es5.js:2770) [angular]
    at ReflectiveInjector_._getByKeyDefault (core.es5.js:2809) [angular]
    at ReflectiveInjector_._getByKey (core.es5.js:2741) [angular]
    at ReflectiveInjector_.get (core.es5.js:2610) [angular]
    at AppModuleInjector.NgModuleInjector.get (core.es5.js:3557) [angular]
    at MySearchModuleInjector.NgModuleInjector.get (core.es5.js:3557) [angular]
    at resolveDep (core.es5.js:10930) [angular]
    at createClass (core.es5.js:10799) [angular]
    at createDirectiveInstance (core.es5.js:10627) [angular]
    at createViewNodes (core.es5.js:11977) [angular]
    at createRootView (core.es5.js:11882) [angular]
    at callWithDebugContext (core.es5.js:13013) [angular]
    at resolvePromise (zone.js:712) [angular]
    at resolvePromise (zone.js:683) [angular]
    at :4200/polyfills.bundle.js:2764:17 [angular]
    at Object.onInvokeTask (core.es5.js:4116) [angular]
    at ZoneDelegate.webpackJsonp.626.ZoneDelegate.invokeTask (zone.js:397) [angular]
    at Zone.webpackJsonp.626.Zone.runTask (zone.js:165) [&lt;root&gt; =&gt; angular]
    at drainMicroTaskQueue (zone.js:593) [&lt;root&gt;]
    at HTMLAnchorElement.ZoneTask.invoke (zone.js:464) [&lt;root&gt;]
defaultErrorLogger @ core.es5.js:1084
ErrorHandler.handleError @ core.es5.js:1144
next @ core.es5.js:4754
schedulerFn @ core.es5.js:3828
SafeSubscriber.__tryOrUnsub @ Subscriber.js:234
SafeSubscriber.next @ Subscriber.js:183
Subscriber._next @ Subscriber.js:125
Subscriber.next @ Subscriber.js:89
Subject.next @ Subject.js:55
EventEmitter.emit @ core.es5.js:3814
NgZone.triggerError @ core.es5.js:4185
onHandleError @ core.es5.js:4146
webpackJsonp.626.ZoneDelegate.handleError @ zone.js:369
webpackJsonp.626.Zone.runGuarded @ zone.js:141
_loop_1 @ zone.js:604
drainMicroTaskQueue @ zone.js:613
ZoneTask.invoke @ zone.js:464
core.es5.js:1084 

ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'canDeactivate' of null
TypeError: Cannot read property 'canDeactivate' of null
    at CanDeactivateGuard.webpackJsonp.224.CanDeactivateGuard.canDeactivate (CanDeactivate.ts:9)
    at MergeMapSubscriber.project (router.es5.js:4394)
    at MergeMapSubscriber._tryNext (mergeMap.js:120)
    at MergeMapSubscriber._next (mergeMap.js:110)
    at MergeMapSubscriber.Subscriber.next (Subscriber.js:89)
    at ArrayObservable._subscribe (ArrayObservable.js:114)
    at ArrayObservable.Observable._trySubscribe (Observable.js:57)
    at ArrayObservable.Observable.subscribe (Observable.js:45)
    at MergeMapOperator.call (mergeMap.js:85)
    at Observable.subscribe (Observable.js:42)
    at EveryOperator.call (every.js:33)
    at Observable.subscribe (Observable.js:42)
    at Object.subscribeToResult (subscribeToResult.js:22)
    at MergeMapSubscriber._innerSub (mergeMap.js:130)
    at MergeMapSubscriber._tryNext (mergeMap.js:127)
    at CanDeactivateGuard.webpackJsonp.224.CanDeactivateGuard.canDeactivate (CanDeactivate.ts:9)
    at MergeMapSubscriber.project (router.es5.js:4394)
    at MergeMapSubscriber._tryNext (mergeMap.js:120)
    at MergeMapSubscriber._next (mergeMap.js:110)
    at MergeMapSubscriber.Subscriber.next (Subscriber.js:89)
    at ArrayObservable._subscribe (ArrayObservable.js:114)
    at ArrayObservable.Observable._trySubscribe (Observable.js:57)
    at ArrayObservable.Observable.subscribe (Observable.js:45)
    at MergeMapOperator.call (mergeMap.js:85)
    at Observable.subscribe (Observable.js:42)
    at EveryOperator.call (every.js:33)
    at Observable.subscribe (Observable.js:42)
    at Object.subscribeToResult (subscribeToResult.js:22)
    at MergeMapSubscriber._innerSub (mergeMap.js:130)
    at MergeMapSubscriber._tryNext (mergeMap.js:127)
    at resolvePromise (zone.js:712) [angular]
    at resolvePromise (zone.js:683) [angular]
    at :4200/polyfills.bundle.js:2764:17 [angular]
    at Object.onInvokeTask (core.es5.js:4116) [angular]
    at ZoneDelegate.webpackJsonp.626.ZoneDelegate.invokeTask (zone.js:397) [angular]
    at Zone.webpackJsonp.626.Zone.runTask (zone.js:165) [&lt;root&gt; =&gt; angular]
    at drainMicroTaskQueue (zone.js:593) [&lt;root&gt;]
    at HTMLAnchorElement.ZoneTask.invoke (zone.js:464) [&lt;root&gt;]
</code></pre></div>
<p dir="auto"><strong>Expected behavior</strong><br>
CanDeactivate guard should not be called with null component and providers should be provided</p>
<p dir="auto"><strong>Minimal reproduction of the problem with instructions</strong></p>

<p dir="auto">Will try to create plnkr when have time.</p>
<p dir="auto"><strong>What is the motivation / use case for changing the behavior?</strong></p>

<p dir="auto">Breaking change. Causes crash in existing code that works as expected in 4.0.0</p>
<p dir="auto"><strong>Please tell us about your environment:</strong></p>

<p dir="auto">@angular/cli: 1.0.0<br>
node: 7.7.1<br>
os: win32 x64<br>
@angular/common: 4.1.0-beta.0<br>
@angular/compiler: 4.1.0-beta.0<br>
@angular/core: 4.1.0-beta.0<br>
@angular/forms: 4.1.0-beta.0<br>
@angular/http: 4.1.0-beta.0<br>
@angular/platform-browser: 4.1.0-beta.0<br>
@angular/platform-browser-dynamic: 4.1.0-beta.0<br>
@angular/router: 4.1.0-beta.0<br>
@angular/cli: 1.0.0<br>
@angular/compiler-cli: 4.1.0-beta.0</p>
<ul dir="auto">
<li><strong>Angular version:</strong> 2.0.X</li>
</ul>

<ul dir="auto">
<li><strong>Browser:</strong> [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 ]</li>
</ul>

<p dir="auto">Only tried in Chrome</p>
<ul dir="auto">
<li>
<p dir="auto"><strong>Language:</strong> [all | TypeScript X.X | ES6/7 | ES5]</p>
</li>
<li>
<p dir="auto"><strong>Node (for AoT issues):</strong> <code class="notranslate">node --version</code> =</p>
</li>
</ul>
<p dir="auto"><strong>I'm submitting a ...</strong>  (check one with "x")</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[x] bug report
[ ] feature request
[ ] support request"><pre class="notranslate"><code class="notranslate">[x] bug report
[ ] feature request
[ ] support request
</code></pre></div>
<p dir="auto"><strong>Current behavior</strong><br>
If an app uses <code class="notranslate">HashLocationStrategy</code> and the URL hash is changed manually, the <code class="notranslate">subscribe</code> observable of the <code class="notranslate">Location</code> service will fire two events for the same change. This will also occur if the browser back/forward buttons are used or when clicking a traditional anchor with <code class="notranslate">href="#foo"</code>.</p>
<p dir="auto"><strong>Expected behavior</strong><br>
The <code class="notranslate">Location</code> service should emit exactly one event for each discrete change in location.</p>
<p dir="auto"><strong>Minimal reproduction of the problem with instructions</strong><br>
See <a href="https://plnkr.co/edit/RBd4TJd9d39aW7VvigHY?p=preview" rel="nofollow">this plunkr</a>. Click the <em>One</em> and <em>Two</em> anchors to see the events logged. You may also want to open the plunkr in a separate window and change the hash manually.<br>
As you can see, two events are logged for each change.</p>
<p dir="auto"><strong>What is the motivation / use case for changing the behavior?</strong><br>
Although <code class="notranslate">Location</code> by itself may cause trouble, the main issue is that each location change event is scheduling a new router navigation. Appearently, the router cannot remember that it is already in the process of changing to an URL and issues a second navigation to the same URL.<br>
The end result is that there will be two router navigations running in parallel. In my experience, it at least causes double invocation of guards/resolvers.</p>
<ul dir="auto">
<li><strong>Angular version:</strong> 2.0.2 up to 2.1.0-rc.0</li>
<li><strong>Browser:</strong> Chrome 53, Firefox 49</li>
<li><strong>Language:</strong> all</li>
</ul>