[PR #431] [MERGED] refactor: make ExecutionContext ALS the single source of truth #567

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/431
Author: @james-elicx
Created: 3/11/2026
Status: Merged
Merged: 3/11/2026
Merged by: @james-elicx

Base: mainHead: refactor/execution-context-als-cleanup


📝 Commits (2)

  • bd547bf refactor: make ExecutionContext ALS the single source of truth
  • 2138897 fix(test): update _handleRequest signature assertion after ctx param removal

📊 Changes

6 files changed (+59 additions, -83 deletions)

View changed files

📝 packages/vinext/src/cloudflare/kv-cache-handler.ts (+3 -16)
📝 packages/vinext/src/entries/app-rsc-entry.ts (+6 -6)
📝 packages/vinext/src/server/isr-cache.ts (+8 -22)
📝 tests/__snapshots__/entry-templates.test.ts.snap (+36 -36)
📝 tests/app-router.test.ts (+1 -1)
📝 tests/isr-cache.test.ts (+5 -2)

📄 Description

Summary

  • Remove `ctx` as an explicit parameter from internal functions (`triggerBackgroundRegeneration`, generated `_handleRequest`) so all downstream code consistently retrieves the Workers `ExecutionContext` via `getRequestExecutionContext()` from the ALS
  • Remove duplicate `ExecutionContext` interface definitions in `isr-cache.ts` and `kv-cache-handler.ts`; use the canonical `ExecutionContextLike` from `shims/request-context.ts`
  • Update `isr-cache.test.ts` to supply `ctx` via `runWithExecutionContext()` (ALS) instead of as a direct argument
  • Update `entry-templates.test.ts` snapshots

Files changed

File Change
`server/isr-cache.ts` Drop `ctx?` param from `triggerBackgroundRegeneration()`; remove duplicate interface
`entries/app-rsc-entry.ts` Drop `ctx` 4th param from generated `_handleRequest`; replace `ctx.waitUntil()` with `_getRequestExecutionContext()?.waitUntil()`
`cloudflare/kv-cache-handler.ts` Remove duplicate `ExecutionContext` interface; use `ExecutionContextLike`
`tests/isr-cache.test.ts` Update `ctx.waitUntil` test to use ALS
`tests/snapshots/entry-templates.test.ts.snap` Regenerated (6 snapshots updated)

🔄 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/431 **Author:** [@james-elicx](https://github.com/james-elicx) **Created:** 3/11/2026 **Status:** ✅ Merged **Merged:** 3/11/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `refactor/execution-context-als-cleanup` --- ### 📝 Commits (2) - [`bd547bf`](https://github.com/cloudflare/vinext/commit/bd547bfb682c3b70b83f6c1bf1db21f22c9100ec) refactor: make ExecutionContext ALS the single source of truth - [`2138897`](https://github.com/cloudflare/vinext/commit/2138897bad306796e6167f85a9a5fad0c21ce90e) fix(test): update _handleRequest signature assertion after ctx param removal ### 📊 Changes **6 files changed** (+59 additions, -83 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/cloudflare/kv-cache-handler.ts` (+3 -16) 📝 `packages/vinext/src/entries/app-rsc-entry.ts` (+6 -6) 📝 `packages/vinext/src/server/isr-cache.ts` (+8 -22) 📝 `tests/__snapshots__/entry-templates.test.ts.snap` (+36 -36) 📝 `tests/app-router.test.ts` (+1 -1) 📝 `tests/isr-cache.test.ts` (+5 -2) </details> ### 📄 Description ## Summary - Remove \`ctx\` as an explicit parameter from internal functions (\`triggerBackgroundRegeneration\`, generated \`_handleRequest\`) so all downstream code consistently retrieves the Workers \`ExecutionContext\` via \`getRequestExecutionContext()\` from the ALS - Remove duplicate \`ExecutionContext\` interface definitions in \`isr-cache.ts\` and \`kv-cache-handler.ts\`; use the canonical \`ExecutionContextLike\` from \`shims/request-context.ts\` - Update \`isr-cache.test.ts\` to supply \`ctx\` via \`runWithExecutionContext()\` (ALS) instead of as a direct argument - Update \`entry-templates.test.ts\` snapshots ## Files changed | File | Change | |------|--------| | \`server/isr-cache.ts\` | Drop \`ctx?\` param from \`triggerBackgroundRegeneration()\`; remove duplicate interface | | \`entries/app-rsc-entry.ts\` | Drop \`ctx\` 4th param from generated \`_handleRequest\`; replace \`ctx.waitUntil()\` with \`_getRequestExecutionContext()?.waitUntil()\` | | \`cloudflare/kv-cache-handler.ts\` | Remove duplicate \`ExecutionContext\` interface; use \`ExecutionContextLike\` | | \`tests/isr-cache.test.ts\` | Update \`ctx.waitUntil\` test to use ALS | | \`tests/__snapshots__/entry-templates.test.ts.snap\` | Regenerated (6 snapshots updated) | --- <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#567
No description provided.