Repository: ReactiveX/rxjs

Issue #3754: Strange behavior with `merge`, `switchMap` and `catchError`
Created: 2018-05-28T18:46:36Z
RxJS version: 6.2.0
Code to reproduce:
merge(this.subjectA.asObservable(), this.subjectB.asObservable())
  .pipe(
    startWith(0),
    // My provider parses the value, but only accepts positive numbers, throwing errors when negative.
    switchMap((value) => { return this.someProvider.willFailWithNegativeNumbers(value); })
    // I don't want the user know this error, so I will just return an empty result
    catchError(() => { return observableOf([]); })
  )
  .subscribe(result => { console.log(result); }

this.subjectA.next(1);
// will console log some valid result, [ ... ]
this.subjectA.next(-1)
// will console log the expected empty array []
this.subjectA.next(1);
// will not enter in the subscribe.

See this stackblitz: https://stackblitz.com/edit/rxjs-yz1cqh?file=app/hello.component.ts
Load console to see the problem!
Note that I emit values for the observable 3 times, but only two of them works.
Expected behavior:
Since the failed call was catch, it should just keep working for subsequent emited values, right?
this.subjectA.next(1); // [ ... ]
this.subjectA.next(-1); // []
this.subjectA.next(1); // [ ... ]

Actual behavior:
this.subjectA.next(1); // [ ... ]
this.subjectA.next(-1); // []
this.subjectA.next(1); // nothing happens

Additional information:

Duplicate issue #3815: `catchError` outside an error observer not working as expected
Created: 2018-06-08T06:20:36Z
Bug Report
Current Behavior
switchMap an ajax observer stop working even with piping catchError outside
Reproduction

REPL or Repo link:
https://jsfiddle.net/JounQin/8ceug61w/

const {
  of,
  ajax: { ajax },
  operators: { catchError, debounceTime, map, switchMap },
} = rxjs

const SERVER_ENDPOINT = 'https://jsonplaceholder.typicode.com/'

const deletPost = id =>
  ajax.delete(SERVER_ENDPOINT + 'posts/' + id).pipe(
    map(() => id),
    // catchError(() => of(null)), // position A
  )

rxjs
  .fromEvent(document.getElementById('input'), 'input')
  .pipe(
    debounceTime(500),
    switchMap(e => deletPost(e.target.value.trim())),
    catchError(() => of(null)), // position B
  )
  .subscribe(console.log)
Input a number less than 100, it will successfully dispatch a delete request, then input a number greater than 100, it will response 404, then whatever you input, switchMap will not work any more, no request will be dispatched.
Expected behavior
It should always request when input changed. I don't know is it working as expected.
Environment

Runtime: Node v10.3.0, Chrome v67.0
RxJS version: 6.2.0

Possible Solution
If we enable code at position A, it will work as expected.
Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.

Closing comment (2018-06-08T06:24:19Z): Dupe of #3754 .
catch to outer observable does not continue outer observable stream, as catch is also terminating condition of observable - it substitute error into some other value, doesn't changes fact error has occurred. As you mentioned in snippet, catch inner observable will allow outer observable continue as error does not bubbles up to upstream.