mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #543] [MERGED] fix: use waitUntil in after() for Cloudflare Workers #659
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#659
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/543
Author: @NathanDrake2406
Created: 3/15/2026
Status: ✅ Merged
Merged: 3/16/2026
Merged by: @james-elicx
Base:
main← Head:fix/after-waituntil📝 Commits (10+)
042caa6fix: use waitUntil in after() to prevent task loss on Cloudflare Workersa518ff6fix: make after() synchronous with static imports per review feedbackc1cd2befix: inline cache-scope check in after() to avoid headers.ts static import93a2773Merge remote-tracking branch 'origin/main' into fix/after-waituntilbe66398address review: fix cache-scope error message and add unstable_cache test for after()2077068fix: use AST directive check before throwing missing-RSC error in use-cache transformfbd0b5efix: tighten AST walker and clarify after() TODO per reviewf4600a5address bonk review: clarify comments and improve test determinism9b37734test: make error-swallowing after() test deterministic0912564Merge remote-tracking branch 'origin/main' into pr-543📊 Changes
3 files changed (+210 additions, -15 deletions)
View changed files
📝
packages/vinext/src/index.ts(+70 -11)📝
packages/vinext/src/shims/server.ts(+69 -3)📝
tests/shims.test.ts(+71 -1)📄 Description
Summary
after()was scheduling tasks as fire-and-forget microtasks viaPromise.resolve().then(task), which are silently dropped when Cloudflare Workers terminate after response completiongetRequestExecutionContext().waitUntil(promise)when an execution context exists, falling back to fire-and-forget for Node.js dev serverthrowIfInsideCacheScope("after()")guard matching Next.js behavior (same pattern asconnection(),headers(),cookies())after()synchronous (function after(): void) with static imports to ensurewaitUntilis registered immediately, not on a deferred microtaskTest plan
after()callswaitUntilon execution context when one existsafter()falls back to fire-and-forget when no execution contextafter()throws inside"use cache"scope🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.