feat: Support async cache stores in revalidation#4826
Merged
metcoder95 merged 3 commits intonodejs:mainfrom Feb 13, 2026
Merged
feat: Support async cache stores in revalidation#4826metcoder95 merged 3 commits intonodejs:mainfrom
metcoder95 merged 3 commits intonodejs:mainfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
metcoder95
reviewed
Feb 13, 2026
Member
metcoder95
left a comment
There was a problem hiding this comment.
lgtm, just need some documentation
Signed-off-by: marcopiraccini <marco.piraccini@gmail.com>
metcoder95
approved these changes
Feb 13, 2026
Merged
slagiewka
pushed a commit
to slagiewka/undici
that referenced
this pull request
Feb 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This relates to...
Cache revalidation failures when using async cache stores (e.g. Redis-backed stores accessed via ITC/remote proxies).
Rationale
When using an async cache store (one whose get() returns a Promise rather than a synchronous value), the cache interceptor has three bugs that prevent proper revalidation:
The combined effect is that cache entries are never refreshed after becoming stale — responses are served with warning: 110 - "response is stale" indefinitely, and the stale-while-revalidate background revalidation silently fails to update the cache.
Changes
lib/interceptor/cache.js, replaced headers = { ...headers, ...result.vary } with a loop that skips entries where the value is null, in both the stale-while-revalidate background revalidation path and the foreground CacheRevalidationHandler path.lib/handler/cache-handler.js, extracted the 304 handling logic into a handle304 callback. After calling this.#store.get(), the result is checked for a .then() method: if it's a Promise (async store), handle304 is deferred via .then(); otherwise it's called synchronously.lib/handler/cache-handler.js, added a Readable stream branch in the 304 handler. When cachedValue.body has a .values() method, the existing array iteration logic is used. When it has an .on() method (Readable stream), the body is piped through the write stream using data/end/error events, with an explicit writeStream.end() on the stream's end event (since onResponseEnd may have already fired before the async handle304 runs).Features
Bug Fixes
N/A
Breaking Changes and Deprecations
N/A
Status