Skip to content

Commit

Permalink
fix(Observable): do not swallow error thrown in subscriber
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj committed May 29, 2017
1 parent cf88a20 commit 05288e3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions spec/Observable-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ describe('Observable', () => {
});
});

it('should not send error to error handler for observable have source', () => {
const source = Observable.of(1);
const observable = new Observable();
(observable as any).source = source;

expect(() => {
observable.subscribe((x) => {
throw new Error('error');
});
}).to.throw();
});

describe('forEach', () => {
it('should iterate and return a Promise', (done: MochaDone) => {
const expected = [1, 2, 3];
Expand Down
2 changes: 1 addition & 1 deletion src/Observable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class Observable<T> implements Subscribable<T> {
if (operator) {
operator.call(sink, this.source);
} else {
sink.add(this._trySubscribe(sink));
sink.add(this.source ? this._subscribe(sink) : this._trySubscribe(sink));
}

if (sink.syncErrorThrowable) {
Expand Down

0 comments on commit 05288e3

Please sign in to comment.