AsapScheduler can interrupt random intervals
### Describe the bug
An interval scheduled somewhere else (including rxjs `timer`) can be unduely canceled by AsapScheduler implementation
1. The timer method calls `scheduler.schedule(callback, 0)` (https://github.com/ReactiveX/rxjs/blob/7.8.2/src/internal/observable/timer.ts#L170C12-L170C30)
2. The asapScheduler generates an immediate ID (https://github.com/ReactiveX/rxjs/blob/7.8.2/src/internal/util/Immediate.ts#L24)
3. The callback reschedules itself calling `schedule(undefined, intervalDuration)`
4. In https://github.com/ReactiveX/rxjs/blob/7.8.2/src/internal/scheduler/AsyncAction.ts#L52, `this.id != null`, so `this.recycleAsyncId(scheduler, id, delay)` is called with the immediate `id` and non-zero delay.
5. asapAction falls back to ayncAction implementation of `recycleAsyncId` because delay is non-zero (https://github.com/ReactiveX/rxjs/blob/7.8.2/src/internal/scheduler/AsapAction.ts#L30)
6. `asynAction.recycleAsyncId` unduely clears an interval with the immediate `id` https://github.com/ReactiveX/rxjs/blob/7.8.2/src/internal/scheduler/AsyncAction.ts#L79
Please verify that my findings are correct
### Expected behavior
The AsapScheduler should be protected in order not to affect unrelated code.
### Reproduction code
```typescript
I could not create a minimal reproducer, but I experienced the bug in production code. My analysis brought to the conclusions above.
```
### Reproduction URL
_No response_
### Version
7.8.2
### Environment
_No response_
### Additional context
_No response_
0 条评论