cli icon indicating copy to clipboard operation
cli copied to clipboard

fix(cache): add limit for PackumentCache.heapLimit

Open dndred opened this issue 1 year ago • 2 comments

The problem

The current implementation of PackumentCache gets heapLimit value from the node runtime. But, in bun, the heap_size_limit: Infinity by default, and it seems there is no way to limit it. Then, the heapLimit value passes to lru-cache cache with doesn't work with unlimited cache size at all.

Trace from lru-cache:

361 |         // NB: maxEntrySize is set to maxSize if it's set
362 |         if (this.maxEntrySize !== 0) {
363 |             if (this.#maxSize !== 0) {
364 |                 console.log('this.#maxSize', this.#maxSize)
365 |                 if (!isPosInt(this.#maxSize)) {
366 |                     throw new TypeError('maxSize must be a positive integer if specified');

Solution

Let's set a reasonable maximum to the heapLimit to avoid this.

dndred avatar Jun 08 '24 14:06 dndred

Is there no other value available to us that lets us make a reasonable guess here? 16GB seems quite large. My system is only a few years old and that value is 4GB for me.

If we have to set a default we're going to want to err more on the side of working for more people, so having any other signal that lets us get closer to a value that will work on a particular system is helpful.

wraithgar avatar Jun 10 '24 14:06 wraithgar