lru-cache known bugs

npm

3 known bugs in lru-cache, with affected versions, fixes and workarounds. Sourced from upstream issue trackers.

3
bugs
Known bugs
SeverityAffectedFixed inTitleStatusSource
mediumany\u2014
Fails in TS Strict Mode
We are trying to enable TS strict mode (`"compilerOptions": {"strict": true}}`, but lru-cache generates the following errors when we try to build our Angular app: ``` ✘ [ERROR] TS2416: Property 'entries' in type 'LRUCache<K, V, FC>' is not assignable to the same property in base type 'Map<K, V>'. Type '() => Generator<[K, V], void, unknown>' is not assignable to type '() => MapIterator<[K, V]>'. Call signature return types 'Generator<[K, V], void, unknown>' and 'MapIterator<[K, V]>' are incompatible. The types returned by 'next(...)' are incompatible between these types. Type 'IteratorResult<[K, V], void>' is not assignable to type 'IteratorResult<[K, V], undefined>'. Type 'IteratorReturnResult<void>' is not assignable to type 'IteratorResult<[K, V], undefined>'. Type 'IteratorReturnResult<void>' is not assignable to type 'IteratorReturnResult<undefined>'. Type 'void' is not assignable to type 'undefined'. [plugin angular-compiler] node_modules/lru-cache/dist/commonjs/index.d.ts:973:4: 973 │ entries(): Generator<[K, V], void, unknown>; ╵ ~~~~~~~ ✘ [ERROR] TS2416: Property 'keys' in type 'LRUCache<K, V, FC>' is not assignable to the same property in base type 'Map<K, V>'. Type '() => Generator<K, void, unknown>' is not assignable to type '() => MapIterator<K>'. Call signature return types 'Generator<K, void, unknown>' and 'MapIterator<K>' are incompatible. The types returned by 'next(...)' are incompatible between these types. Type 'IteratorResult<K, void>' is not assignable to type 'IteratorResult<K, undefined>'. Type 'IteratorReturnResult<void>' is not assignable to type 'IteratorResult<K, undefined>'. Type 'IteratorReturnResult<void>' is not assignable to type 'IteratorReturnResult<undefined>'. Type 'void' is not assignable to type 'undefined'. [plugin angular-compiler] node_modules/lru-cache/dist/commonjs/index.d.ts:985:4: 985 │ keys(): Generator<K, void, unknown>; ╵ ~~~~ ✘ [ERROR] TS2416: Property 'values' in type 'LRUCache<K, V, FC>' is not assignable to the same property in base type 'Map<K, V>'. Type '() => Generator<V, void, unknown>' is not assignable to type '() => MapIterator<V>'. Call signature return types 'Generator<V, void, unknown>' and 'MapIterator<V>' are incompatible. The types returned by 'next(...)' are incompatible between these types. Type 'IteratorResult<V, void>' is not assignable to type 'IteratorResult<V, undefined>'. Type 'IteratorReturnResult<void>' is not assignable to type 'IteratorResult<V, undefined>'. Type 'IteratorReturnResult<void>' is not assignable to type 'IteratorReturnResult<undefined>'. Type 'void' is not assignable to type 'undefined'. [plugin angular-compiler] node_modules/lru-cache/dist/commonjs/index.d.ts:997:4: 997 │ values(): Generator<V, void, unknown>; ╵ ~~~~~~ ✘ [ERROR] TS2416: Property '[Symbol.iterator]' in type 'LRUCache<K, V, FC>' is not assignable to the same property in base type 'Map<K, V>'. Type '() => Generator<[K, V], void, unknown>' is not assignable to type '() => MapIterator<[K, V]>'. Call signature return types 'Generator<[K, V], void, unknown>' and 'MapIterator<[K, V]>' are incompatible. The types returned by 'next(...)' are incompatible between these types. Type 'IteratorResult<[K, V], void>' is not assignable to type 'IteratorResult<[K, V], undefined>'. Type 'IteratorReturnResult<void>' is not assignable to type 'IteratorResult<[K, V], undefined>'. Type 'IteratorReturnResult<void>' is not assignable to type 'IteratorReturnResult<undefined>'. Type 'void' is not assignable to type 'undefined'. [plugin angular-compiler] node_modules/lru-cache/dist/commonjs/index.d.ts:1009:4: 1009 │ [Symbol.iterator](): Generator<[K, V], void, unknown>; ╵ ~~~~~~~~~~~~~~~~~ ✘ [ERROR] TS2416: Property 'forEach' in type 'LRUCache<K, V, FC>' is not assignable to the same property in base type 'Map<K, V>'. Type '(fn: (v: V, k: K, self: LRUCache<K, V, FC>) => any, thisp?: any) => void' is not assignable to type '(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any) => void'. Types of parameters 'fn' and 'callbackfn' are incompatible. Types of parameters 'map' and 'self' are incompatible. Type 'LRUCache<K, V, FC>' is not assignable to type 'Map<K, V>'. The types returned by 'entries().next(...)' are incompatible between these types. Type 'IteratorResult<[K, V], void>' is not assignable to type 'IteratorResult<[K, V], undefined>'. Type 'IteratorReturnResult<void>' is not assignable to type 'IteratorResult<[K, V], undefined>'. Type 'IteratorReturnResult<void>' is not assignable to type 'IteratorReturnResult<undefined>'. Type 'void' is not assignable to type 'undefined'. [plugin angular-compiler] node_modules/lru-cache/dist/commonjs/index.d.ts:1032:4: 1032 │ forEach(fn: (v: V, k: K, self: LRUCache<K, V, FC>) => any, thisp?: any): void; ``` These errors seem to be with the type definitions of the library, and not our code.
fixedgithub:383
medium11.3.0\u2014
Memory leak error
After getting `lru-cache` to `11.3.0` I am getting `Eventemitter` memory leak error while running ng test in an angular application <img width="1606" height="77" alt="Image" src="https://github.com/user-attachments/assets/28251ca7-c929-454a-a2ac-5c443890fc15" /> Fixed with overrides for now ``` "overrides": { "lru-cache": "11.2.7" }
fixedgithub:396
medium11.3.3\u2014
Importing the package in react-native fails
After updating to the latest version 11.3.3 in our Expo 55 project, we get this error: > The package at "node_modules/lru-cache/dist/esm/index.min.js" attempted to import the Node standard library module "node:diagnostics_channel". > It failed because the native React runtime does not include the Node standard library. > Learn more: https://docs.expo.dev/workflow/using-libraries/#using-third-party-libraries We applied a workaround by manually handling it in our metro.config.ts: ```ts config.resolver.resolveRequest = (context, moduleName, platform) => { if (moduleName === 'node:diagnostics_channel') { return { type: 'empty' } } // ... } ``` It would be nice if it would natively work. I also reported this to the [relevant Expo discussion](https://github.com/expo/expo/discussions/36551#discussioncomment-16501522).
fixedgithub:399
API access

Get this data programmatically \u2014 free, no authentication.

curl https://depscope.dev/api/bugs/npm/lru-cache
lru-cache bugs — known issues per version | DepScope | DepScope