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

Issue with faked performance.now and this.starts being zeros #379

Open
domarmstrong opened this issue Jan 16, 2025 · 0 comments
Open

Issue with faked performance.now and this.starts being zeros #379

domarmstrong opened this issue Jan 16, 2025 · 0 comments

Comments

@domarmstrong
Copy link

domarmstrong commented Jan 16, 2025

I'm seeing another issue with using sinon timers. With a faked performance.now, the initial result will be 0 until you advance the timer.

But the default fill of the starts array is 0 https://github.com/isaacs/node-lru-cache/blob/main/src/index.ts#L1478. That means any value set in the cache before you manually advance a timer is seem as not having a TTL.

You could argue in a real world situation you won't get a performance.now of 0. I think ideally the starts array should be initialised with null/undefineds instead? It seems like a bug that a cache with a ttl set should see it as not having a ttl because perf.now returned 0.

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

1 participant