ptarjan / node-cache

A simple in-memory cache for nodejs
BSD 2-Clause "Simplified" License
1.59k stars 214 forks source link

Unref`d cache timer to prevent event loop hanging #95

Closed awolden closed 3 years ago

awolden commented 6 years ago

The timeout handler for the cache was never unreferenced so it would hold the event loop open even after the program had finished running. We were running into this issue when attempting to the use the cache within lambdas.

https://nodejs.org/api/timers.html#timers_timeout_unref

seanohollaren commented 6 years ago

Seconding this PR. node-cache currently cannot be used in lambdas without using an undesirable option which forcibly kills the lambda without waiting for the event loop to be empty.