-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugConfirmed bugConfirmed bug
Description
Bug Report
Current Behavior
In the sample code below, the TypeError is not caught in the catchError callback, but thrown globally. We can not detect the error in the observable stream and in NodeJS environment this error can cause the whole application to shut down.
(If the provided mergeMap callback throws an Error instead of returning null, the error is handled correctly.)
Reproduction
- REPL or Repo link: https://stackblitz.com/edit/rxjs-uncaught?file=index.ts
of(1).pipe(
// Without the next line, the error is caught correctly
mergeMap(async () => 2),
// This usage should produce a runtime TypeError: You provided 'null' where a stream was expected.
mergeMap(() => null),
catchError(error => {
console.error('Error in the stream caught:', error.message);
return [];
})
).subscribe();Expected behavior
The TypeError should not leave the observable stream, should be catchable by catchError the same way like when the mergeMap(async () => 2) line does not present.
Environment
- Runtime: Node v12.10.0, Chrome v80.0.3987.122
- RxJS version: 6.5.4
Possible Solution
Not a solution, just a very hacky workaround for somebody who is affected by this bug: https://stackblitz.com/edit/rxjs-uncaught?file=patch.ts
Metadata
Metadata
Assignees
Labels
bugConfirmed bugConfirmed bug