ReactiveX/rxjs

'.now()' is not a function error is thrown when the value of DateTimestampProvider.delegate is not valid

dcarabott opened this issue · 1 comments

Describe the bug

Recently migrated from 6.6.3 to 7.8.1

Have been noticing errors popping up from the following provider:

export const dateTimestampProvider: DateTimestampProvider = {
  now() {
    // Use the variable rather than `this` so that the function can be called
    // without being bound to the provider.
    return (dateTimestampProvider.delegate || Date).now();
  },
  delegate: undefined,
};

The delegate is sometimes set as an empty object. That will of course throw an error when '.now()' is called elsewhere. This can be observed when using ReplaySubject (line 100)

The problem here is that I couldn't consistently replicate this issue and I didn't manage to figure out exactly what's going on.

UPDATE:
I managed to find the issue. It was on our side. We were deep merging some objects and managed to change the value of some. This provider being a global value should feature better validation when updating

Expected behaviour

Delegate shouldn't be allowed to be assigned an invalid value. Some kind of validation should be setup when setting the value.

Version

7.8.1

I managed to find only one instance on the TestScheduler

I think this was introduced to enable TestScheduler to work without having to manually pass schedulers to operators.

Could you please provide a reproduction example?