forked from angular/angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(zone.js): zone.js patches rxjs should check null for unsubscribe (a…
…ngular#35990) Close angular#31687, angular#31684 Zone.js patches rxjs internal `_subscribe` and `_unsubscribe` methods, but zone.js doesn't do null check, so in some operator such as `retryWhen`, the `_unsubscribe` will be set to null, and will cause zone patched version throw error. In this PR, if `_subscribe` and `_unsubscribe` is null, will not do the patch. PR Close angular#35990
- Loading branch information
1 parent
5463462
commit 3fa8952
Showing
3 changed files
with
87 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* @license | ||
* Copyright Google Inc. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
import {Observable, of , timer} from 'rxjs'; | ||
import {delayWhen, map, retryWhen} from 'rxjs/operators'; | ||
|
||
describe('Observable.retryWhen', () => { | ||
let log: any[]; | ||
let observable1: Observable<any>; | ||
let defaultTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; | ||
|
||
beforeEach(() => { | ||
log = []; | ||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; | ||
}); | ||
|
||
afterEach(() => { jasmine.DEFAULT_TIMEOUT_INTERVAL = defaultTimeout; }); | ||
|
||
it('retryWhen func callback should run in the correct zone', (done: DoneFn) => { | ||
const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone'}); | ||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); | ||
let isErrorHandled = false; | ||
observable1 = constructorZone1.run(() => { | ||
return of (1, 2, 3).pipe( | ||
map(v => { | ||
if (v > 2 && !isErrorHandled) { | ||
isErrorHandled = true; | ||
throw v; | ||
} | ||
return v; | ||
}), | ||
retryWhen(err => err.pipe(delayWhen(v => timer(v))))); | ||
}); | ||
|
||
subscriptionZone.run(() => { | ||
observable1.subscribe( | ||
(result: any) => { | ||
log.push(result); | ||
expect(Zone.current.name).toEqual(subscriptionZone.name); | ||
}, | ||
(err: any) => { fail('should not call error'); }, | ||
() => { | ||
log.push('completed'); | ||
expect(Zone.current.name).toEqual(subscriptionZone.name); | ||
expect(log).toEqual([1, 2, 1, 2, 3, 'completed']); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters