Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dcarabott opened this issue Dec 4, 2023 · 1 comment

Comments

@dcarabott
Copy link

dcarabott commented Dec 4, 2023

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

@dcarabott dcarabott changed the title '.now()' is not a function error is thrown when the value of DateTimestampProvider.delegate is an empty object '.now()' is not a function error is thrown when the value of DateTimestampProvider.delegate is not valid Dec 4, 2023
@jakovljevic-mladen
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants