Skip to content

Commit

Permalink
fix(Observable): errors thrown in observer/handlers without an operat…
Browse files Browse the repository at this point in the history
…or applied will no longer be swallowed (#2626)

- closes #2565
  • Loading branch information
kwonoj authored and benlesh committed Jun 14, 2017
1 parent 25a3d64 commit c250afc
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 @@ -198,7 +198,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 c250afc

Please sign in to comment.