[PR #432] [MERGED] fix(fetch-cache): register stale-while-revalidate refetch with waitUntil() #569

Closed
opened 2026-05-06 13:08:48 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/432
Author: @Divkix
Created: 3/11/2026
Status: Merged
Merged: 3/11/2026
Merged by: @james-elicx

Base: mainHead: fix/fetch-cache-waituntil


📝 Commits (2)

  • 37dc4db fix(fetch-cache): register stale-while-revalidate refetch with waitUntil()
  • 99497ea ci: re-trigger CI

📊 Changes

2 files changed (+41 additions, -2 deletions)

View changed files

📝 packages/vinext/src/shims/fetch-cache.ts (+6 -2)
📝 tests/fetch-cache.test.ts (+35 -0)

📄 Description

Fixes #438

Summary

  • Register the fetch cache's background refetch promise with ExecutionContext.waitUntil() so Cloudflare Workers keeps the isolate alive until the refetch completes
  • Without this fix, stale entries on Workers never get refreshed because the isolate terminates after the response is sent, killing the in-flight fire-and-forget refetch
  • Uses the existing getRequestExecutionContext() ALS accessor, matching the pattern already used by ISR in isr-cache.ts

Test plan

  • New test: registers stale background refetch with waitUntil when ExecutionContext is available — creates mock ExecutionContext, populates cache, expires entry, triggers stale hit, asserts waitUntil was called with the refetch promise
  • All 74 existing fetch-cache tests pass
  • Typecheck passes
  • Lint passes
  • Format passes

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/432 **Author:** [@Divkix](https://github.com/Divkix) **Created:** 3/11/2026 **Status:** ✅ Merged **Merged:** 3/11/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `fix/fetch-cache-waituntil` --- ### 📝 Commits (2) - [`37dc4db`](https://github.com/cloudflare/vinext/commit/37dc4db9d1b9d1356e054f778a858aa93ba75aaa) fix(fetch-cache): register stale-while-revalidate refetch with waitUntil() - [`99497ea`](https://github.com/cloudflare/vinext/commit/99497ea9d625655ec8c8ed6b425a548c7d3f06b5) ci: re-trigger CI ### 📊 Changes **2 files changed** (+41 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/shims/fetch-cache.ts` (+6 -2) 📝 `tests/fetch-cache.test.ts` (+35 -0) </details> ### 📄 Description Fixes #438 ## Summary - Register the fetch cache's background refetch promise with `ExecutionContext.waitUntil()` so Cloudflare Workers keeps the isolate alive until the refetch completes - Without this fix, stale entries on Workers never get refreshed because the isolate terminates after the response is sent, killing the in-flight fire-and-forget refetch - Uses the existing `getRequestExecutionContext()` ALS accessor, matching the pattern already used by ISR in `isr-cache.ts` ## Test plan - [x] New test: `registers stale background refetch with waitUntil when ExecutionContext is available` — creates mock ExecutionContext, populates cache, expires entry, triggers stale hit, asserts `waitUntil` was called with the refetch promise - [x] All 74 existing fetch-cache tests pass - [x] Typecheck passes - [x] Lint passes - [x] Format passes --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:08:48 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#569
No description provided.