Closed nornagon closed 1 year ago
Ah, I think I might have a lead as to what's going on... let me know if this sounds like it could plausibly be the cause of the behavior above:
index
now points to an invalid entry, because it was removed from the data structureset()
carries on and calls moveToTail()
on an invalid index, corrupting the data structureAdded a failing test over in https://github.com/isaacs/node-lru-cache/pull/270 that illustrates this behavior. I'm pretty confident now that the above scenario is the cause of this behavior.
I was observing some strange OOM behavior, which I think turned out to be an unboundedly-large
free
list similar to #227. I added some diagnostics and it looked likeevict
was being called when there was nothing left in the cache to evict, because thecalculatedSize
was not correct.I added the following check:
and discovered that while this passes all tests, this check trips in my usage:
i.e. when the
cb
comes back from afetch()
promise, andset
is called, it results in an inconsistency between the sizes insizes
and the totalcalculatedSize
.I haven't yet tracked down the root cause of this, but in case you have some ideas I thought I'd throw a bug up here!