-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Subscription): fix leaks caused by unsubscribe functions that throw
- adds a test for the issue related #1256
- Loading branch information
Showing
5 changed files
with
80 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* globals describe, it, expect */ | ||
var Rx = require('../dist/cjs/Rx'); | ||
var Subscription = Rx.Subscription; | ||
var Observable = Rx.Observable; | ||
|
||
describe('Subscription', function () { | ||
it('should not leak', function (done) { | ||
var tearDowns = []; | ||
|
||
var source1 = Observable.create(function (observer) { | ||
return function () { | ||
tearDowns.push(1); | ||
}; | ||
}); | ||
|
||
var source2 = Observable.create(function (observer) { | ||
return function () { | ||
tearDowns.push(2); | ||
throw new Error('oops, I am a bad unsubscribe!'); | ||
}; | ||
}); | ||
|
||
var source3 = Observable.create(function (observer) { | ||
return function () { | ||
tearDowns.push(3); | ||
}; | ||
}); | ||
|
||
var subscription = Observable.merge(source1, source2, source3).subscribe(); | ||
|
||
setTimeout(function () { | ||
expect(function () { | ||
subscription.unsubscribe(); | ||
}).toThrow(); | ||
expect(tearDowns).toEqual([1, 2, 3]); | ||
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
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
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