Skip to content

Comments

Found a few bugs while reading through the source. All minimal fixes, no refactoring, no new files.#1

Open
sur-ser wants to merge 1 commit intom8a-io:mainfrom
sur-ser:main
Open

Found a few bugs while reading through the source. All minimal fixes, no refactoring, no new files.#1
sur-ser wants to merge 1 commit intom8a-io:mainfrom
sur-ser:main

Conversation

@sur-ser
Copy link

@sur-ser sur-ser commented Feb 18, 2026

Fixes

P1: Falsy cached values treated as cache misses

cacheable.interceptor.tsif (cachedValue) fails for 0, false, "". The cacheable library returns undefined on miss, so changed to !== undefined.

P2: HTTP method not included in cache key

cacheable.interceptor.tsGET /users and POST /users produce the same cache key, causing cross-method pollution. Added method to key.

P2: Cache write failure kills valid response

cacheable.interceptor.ts — If set() throws (Redis down), the already-computed response is lost. Made cache write fire-and-forget so the response always returns. Note: the error is silently swallowed since the interceptor has no Logger instance — worth adding one later to catch Redis failures.

P2: JSON.stringify in logger crashes on circular references

nestjs-cacheable.service.ts — Debug log with JSON.stringify(value) throws on circular objects, crashing set(). Wrapped in try/catch.

P2: disconnect() leaks primary store connections

nestjs-cacheable.service.tsdisconnect() only closes secondary. Used Cacheable.disconnect() which handles both stores.

No breaking changes

All fixes are backward-compatible. No new files, no refactoring, no API changes.

1. P1: Falsy cached values (0, false, "", null) treated as cache misses
   - Changed `if (cachedValue)` to `if (cachedValue !== undefined)`

2. P2: HTTP method not included in cache key
   - Changed key from `request.url` to `${request.method}:${request.url}`

3. P2: Cache write failure prevents valid response from being returned
   - Made cache set fire-and-forget with `.catch(() => {})`

4. P2: JSON.stringify in logger throws on circular references
   - Wrapped in try/catch to prevent logging from crashing set()

5. P2: disconnect() only disconnects secondary, leaks primary connections
   - Replaced manual secondary disconnect with `this.cache.disconnect()`

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant