You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are using @sinonjs/fake-timers and have gotten an issue where items with a ttl doesn’t expire as we progress the time. It seems like lru-cache will not use the fake timers unless they are installed before the first require/import of lru-cache. Since it can be quite hard to control the order of how code is loaded/imported in larger projects this can create some subtle bugs within tests.
Digging into the code I assume the issue stems from lru-cache saving a reference to performance or Date when you load the module the first time and this will reference the real functions if you haven’t installed the fakers yet.
This issue might just be related to our setup where we install and uninstall the fake timers depending on if the test needs them and keeping the servers alive between tests to save time.
A possible solution could be an function that allows you to update or refresh the internal reference something like #refreshTTLTimerRefrence that just reruns the code to find the correct timer.
We are using
@sinonjs/fake-timers
and have gotten an issue where items with attl
doesn’t expire as we progress the time. It seems likelru-cache
will not use the fake timers unless they are installed before the first require/import oflru-cache
. Since it can be quite hard to control the order of how code is loaded/imported in larger projects this can create some subtle bugs within tests.Digging into the code I assume the issue stems from
lru-cache
saving a reference toperformance
orDate
when you load the module the first time and this will reference the real functions if you haven’t installed the fakers yet.This issue might just be related to our setup where we install and uninstall the fake timers depending on if the test needs them and keeping the servers alive between tests to save time.
Reproduction repository: https://github.com/Milkywire/node-lru-cache-test-issue
A possible solution could be an function that allows you to update or refresh the internal reference something like
#refreshTTLTimerRefrence
that just reruns the code to find the correct timer.This could then be part of
unsafeExposeInternals
and used if needed.What do you think?
The text was updated successfully, but these errors were encountered: