| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
…stale-if-error RFC 9111 §5.2.2.2: a cache MUST NOT use a stale response with must-revalidate to satisfy any request without successful validation — this takes precedence over the request's max-stale grace (§5.2.1.2) and excludes the response from stale-if-error (RFC 5861 §4). proxy-revalidate (§5.2.2.8) has the same semantics for shared caches (the interceptor's default type) and was parsed but never enforced. Before: store `200 Cache-Control: max-age=1, must-revalidate` (+ ETag), wait past staleness, request with `Cache-Control: max-stale=600` — the stale response is served straight from cache with zero origin contact. After: a conditional request is sent to the origin and the cached response is only reused on successful validation. isStale() now skips the max-stale grace window and handleResult() skips the stale-if-error threshold when the stored response carries must-revalidate (or proxy-revalidate on a shared cache). Fixes nodejs#5508 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #5511 +/- ##
=======================================
Coverage 93.44% 93.44%
=======================================
Files 110 110
Lines 37328 37345 +17
=======================================
+ Hits 34881 34898 +17
Misses 2447 2447 ☔ View full report in Codecov by Harness.
|
Sorry, something went wrong.
'Should end h2 zero-length request bodies with headers' failed with ERR_OSSL_ASN1_ILLEGAL_PADDING from a runtime-generated self-signed cert (@metcoder95/https-pem). The plain Node 26/ubuntu job passed on the same commit and the test passes locally on this branch and on main; this PR only touches lib/interceptor/cache.js. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Addresses review feedback by tightening the forbidsServingStale JSDoc to match undici's terse comment style; RFC references retained. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
lgtm
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
What
The cache interceptor's isStale() granted the request max-stale grace window without consulting the stored response's directives, and handleResult() applied the stale-if-error threshold unconditionally.
RFC 9111 §5.2.2.2: a cache MUST NOT use a stale response with must-revalidate to satisfy any request without successful validation — this overrides the request's max-stale (see the note in §5.2.1.2) and also excludes the response from stale-if-error (RFC 5861 §4). proxy-revalidate has the same semantics for shared caches — the interceptor's default type — and was parsed but never enforced anywhere.
Fixes #5508
Repro
Store 200 Cache-Control: max-age=1, must-revalidate (+ ETag), wait past staleness, then request with Cache-Control: max-stale=600:
Same for stale-if-error: a stale must-revalidate response was previously served when revalidation returned a 5xx within the stale-if-error window; now the error is propagated.
Changes
Testing
Notes
🤖 Generated with Claude Code