Skip to content

throttleTime does not ignore subsequent sources if next is in subscribe #7040

Description

@CorentinHardy

Describe the bug

I recently update from version 6.6 to version 7.5. I found some infinite loop in my code due to throttleTime that didn't work as it used to. We are calling in our subscribe some method that may emit new value on the subscribed observable. throtteTime filtered those values, but it let them pass in version 7.5.6 . Now it behave as it was only synchronous.

Expected behavior

throttleTime should still ignore subsequent sources even if they were emitted in subscribe.

Reproduction code

testThrotteTimeWithNextInSubscribe() {
    const d_1 = new Date().getTime();
    const subject = new Subject<{iteration: number, name: string}>();
    subject.pipe(
      tap((tic) => console.debug('at', new Date().getTime() - d_1, 'tap', tic)),
      throttleTime(10000)
    ).subscribe((me) => {
      console.log('at', new Date().getTime() - d_1, 'subscribe', me);
      if (me.iteration < 10) {
        subject.next({iteration: me.iteration + 1, name: me.name + '-a'});
        subject.next({iteration: me.iteration + 1, name: me.name + '-b'});
      }
    });
    subject.next({iteration: 1, name: 'bug'});
  }

Reproduction URL

No response

Version

7.5.6

Environment

node 14.19.3
typescript 4.6.4

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions