[PR #429] [MERGED] fix(isr): use getRequestExecutionContext() from ALS in background regeneration #566

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

📋 Pull Request Information

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

Base: mainHead: opencode/brave-wizard


📝 Commits (1)

  • 433e1fd fix(isr): use getRequestExecutionContext() from ALS in background regeneration

📊 Changes

3 files changed (+31 additions, -22 deletions)

View changed files

📝 packages/vinext/src/entries/app-rsc-entry.ts (+4 -3)
📝 packages/vinext/src/server/isr-cache.ts (+3 -1)
📝 tests/__snapshots__/entry-templates.test.ts.snap (+24 -18)

📄 Description

Summary

  • __triggerBackgroundRegeneration in app-rsc-entry.ts was receiving ctx as a parameter from the outer request handler, but by the time the stale-while-revalidate branch executed, that reference could be stale or absent — causing waitUntil() to never be called and the Workers isolate to terminate before the revalidation completed
  • Fix: call getRequestExecutionContext() (AsyncLocalStorage-backed) inside the function to always retrieve the live ExecutionContext for the current request
  • Same fallback added to isr-cache.ts's triggerBackgroundRegeneration so the dev-server path (which passes no ctx) also benefits

🔄 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/429 **Author:** [@james-elicx](https://github.com/james-elicx) **Created:** 3/10/2026 **Status:** ✅ Merged **Merged:** 3/10/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `opencode/brave-wizard` --- ### 📝 Commits (1) - [`433e1fd`](https://github.com/cloudflare/vinext/commit/433e1fdf7e53ed3b452334c8ec36481b8375b907) fix(isr): use getRequestExecutionContext() from ALS in background regeneration ### 📊 Changes **3 files changed** (+31 additions, -22 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/entries/app-rsc-entry.ts` (+4 -3) 📝 `packages/vinext/src/server/isr-cache.ts` (+3 -1) 📝 `tests/__snapshots__/entry-templates.test.ts.snap` (+24 -18) </details> ### 📄 Description ## Summary - `__triggerBackgroundRegeneration` in `app-rsc-entry.ts` was receiving `ctx` as a parameter from the outer request handler, but by the time the stale-while-revalidate branch executed, that reference could be stale or absent — causing `waitUntil()` to never be called and the Workers isolate to terminate before the revalidation completed - Fix: call `getRequestExecutionContext()` (AsyncLocalStorage-backed) inside the function to always retrieve the live `ExecutionContext` for the current request - Same fallback added to `isr-cache.ts`'s `triggerBackgroundRegeneration` so the dev-server path (which passes no `ctx`) also benefits --- <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:47 +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#566
No description provided.