Skip to content

Commit

Permalink
fix(bindNodeCallback): now emits errors that happen after callback
Browse files Browse the repository at this point in the history
- No longer logs to console warn
- AsyncSubject overhead no longer required
- Inlined the deprecated scheduled path
  • Loading branch information
benlesh committed Aug 26, 2020
1 parent 54ace0b commit edc28cf
Show file tree
Hide file tree
Showing 2 changed files with 235 additions and 136 deletions.
17 changes: 8 additions & 9 deletions spec/observables/bindNodeCallback-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,17 +279,16 @@ describe('bindNodeCallback', () => {
expect(results2).to.deep.equal([42, 'done']);
});

it('should not swallow post-callback errors', () => {
it('should emit post callback errors', () => {
function badFunction(callback: (error: Error, answer: number) => void): void {
callback(null as any, 42);
throw new Error('kaboom');
}
const consoleStub = sinon.stub(console, 'warn');
try {
bindNodeCallback(badFunction)().subscribe();
expect(consoleStub).to.have.property('called', true);
} finally {
consoleStub.restore();
throw 'kaboom';
}
let receivedError: any;
bindNodeCallback(badFunction)().subscribe({
error: err => receivedError = err
});

expect(receivedError).to.equal('kaboom');
});
});
Loading

0 comments on commit edc28cf

Please sign in to comment.