Repository navigation
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #346 +/- ##
==========================================
+ Coverage 95.74% 95.76% +0.01%
==========================================
Files 9 9
Lines 1011 1015 +4
Branches 352 357 +5
==========================================
+ Hits 968 972 +4
Misses 41 41
Partials 2 2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The
if-modified-sincecheck in the handler has two problems:1. It never matches a real file's mtime.
last-modifiedis sent withmtime.toUTCString(), which has second precision. The check then compares the client's echoed date against the full mtime,new Date(ifModifiedSince) >= sourceMeta.mtime. File mtimes almost always have a sub-second part, so the echoed date is always slightly earlier and the request is answered with a full 200. Revalidation only works when the client also sendsif-none-match.With
ipxFSStorageovertest/assets:2. It runs before, and regardless of,
if-none-match. RFC 9110 §13.1.3 says a recipient MUST ignoreIf-Modified-Sinceif the request containsIf-None-Match, because the entity tag is the more accurate validator. Here a request whoseif-none-matchdoesn't match, but whoseif-modified-sinceis not older than the mtime, gets a 304. The client then keeps a response the ETag says is stale:The fix reads
if-modified-sinceonly when there is noif-none-match, and compares it against the mtime truncated to whole seconds. Truncating matches whatlast-modifiedsends;Date.parse()returnsNaNfor an invalid date, so the comparison is false as before. This is the same behavior h3 (utils/internal/cache.ts) and srvx (static.ts) already implement.Tests: two cases in the
conditional requestsblock oftest/server.test.ts, one with a.500mtime and one with a non-matchingif-none-matchplusif-modified-since. Both fail without the change. The existingif-modified-sincetest used a whole-second mtime, which is why it passed.pnpm testpasses (lint,tsc --noEmitafterpnpm buildfor the examples, and vitest with coverage).Summary by CodeRabbit