Skip to content

Commit 619c4aa

Browse files
committed
fixup! minor code factoring
1 parent d7b051f commit 619c4aa

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

packages/cloudflare/src/api/overrides/tag-cache/d1-next-tag-cache.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,9 @@ export class D1NextModeTagCache implements NextModeTagCache {
109109
// A tag is stale when both its stale and revalidatedAt timestamps are newer than the page.
110110
// revalidatedAt > lastModified ensures the revalidation that set this stale window happened
111111
// after the page was generated, preventing a stale signal from a previous ISR cycle.
112+
const lastModifiedOrNow = lastModified ?? now;
112113
const isInStaleWindow =
113-
stale != null && revalidatedAt > (lastModified ?? now) && (lastModified ?? now) <= stale;
114+
stale != null && revalidatedAt > lastModifiedOrNow && lastModifiedOrNow <= stale;
114115
if (!isInStaleWindow) return false;
115116
return expire == null || expire > now;
116117
});

packages/cloudflare/src/api/overrides/tag-cache/do-sharded-tag-cache.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,9 @@ class ShardedDOTagCache implements NextModeTagCache {
195195
// A tag is stale when both its stale timestamp and its revalidatedAt are newer than the page.
196196
// revalidatedAt > lastModified ensures the revalidation that set this stale window happened
197197
// after the page was generated, preventing a stale signal from a previous ISR cycle.
198+
const lastModifiedOrNow = lastModified ?? now;
198199
const isInStaleWindow =
199-
stale != null && revalidatedAt > (lastModified ?? now) && (lastModified ?? now) <= stale;
200+
stale != null && revalidatedAt > lastModifiedOrNow && lastModifiedOrNow <= stale;
200201
if (!isInStaleWindow) return false;
201202
return expire == null || expire > now;
202203
});

packages/cloudflare/src/api/overrides/tag-cache/kv-next-tag-cache.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,9 @@ export class KVNextModeTagCache implements NextModeTagCache {
184184
// A tag is stale when both its stale timestamp and its revalidatedAt are newer than the page.
185185
// revalidatedAt > lastModified ensures the revalidation that set this stale window happened
186186
// after the page was generated, preventing a stale signal from a previous ISR cycle.
187+
const lastModifiedOrNow = lastModified ?? now;
187188
const isInStaleWindow =
188-
stale != null && getRevalidatedAt(v) > (lastModified ?? now) && (lastModified ?? now) <= stale;
189+
stale != null && getRevalidatedAt(v) > lastModifiedOrNow && lastModifiedOrNow <= stale;
189190
if (!isInStaleWindow) return false;
190191
return expire == null || expire > now;
191192
});

0 commit comments

Comments
 (0)