switchMap not unsubscribing depending on import of Observable
See original GitHub issueRxJS version: 5.5.6
In our app, we today encountered an issue with code which is essentially the same as the following.
[Removed in favor of the repository with a reproducable version posted below]
The behavior we saw was that all the (temporarily) started timers kept executing in parallel, as if switchMap
didn’t unsubscribe from it when id$
emitted.
After a lot of debugging, I eventually figured out that the bug only arises when Observable
is imported as
import { Observable } from "rxjs";
but not when imported as
import { Observable } from "rxjs/Observable";
Unfortunately, I cannot reproduce the issue on Stackblitz independently of how I import. My feeling here is that there is some dependency which patches Observable
, perhaps with an older, faulty version or something.
However, the problem I am having with this theory: I would think that in this case it breaks when importing from rxjs/Observable
, but not when importing rxjs
. But what we see is exactly the opposite.
I realize that with rxjs 5.5.0, patching Observable isn’t the choice of things anymore and we do intend to move away from this. In the mean time, I would really like to understand how importing from rxjs
breaks behavior so drastically and would appreciate any ideas on how to figure out what is messing with us here.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:11 (5 by maintainers)
Reproduce steps:
https://github.com/kayjtea/rxjs3306
The problem arises from mixing the full RxJS import with the patch mechanism.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.