mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #493] [MERGED] fix: register reportRequestError with ctx.waitUntil on Workers #615
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#615
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/493
Author: @NathanDrake2406
Created: 3/12/2026
Status: ✅ Merged
Merged: 3/12/2026
Merged by: @james-elicx
Base:
main← Head:fix/report-request-error-waituntil📝 Commits (1)
687397bfix: register reportRequestError with ctx.waitUntil on Workers📊 Changes
7 files changed (+83 additions, -83 deletions)
View changed files
📝
packages/vinext/src/entries/app-rsc-entry.ts(+3 -9)📝
packages/vinext/src/entries/pages-server-entry.ts(+2 -2)📝
packages/vinext/src/server/api-handler.ts(+1 -3)📝
packages/vinext/src/server/dev-server.ts(+1 -3)📝
packages/vinext/src/server/instrumentation.ts(+21 -10)📝
tests/__snapshots__/entry-templates.test.ts.snap(+20 -56)📝
tests/instrumentation.test.ts(+35 -0)📄 Description
Summary
Follow-up to #492. On Cloudflare Workers, the isolate can terminate after the Response is sent, killing in-flight error reports (e.g. Sentry HTTP requests) that were fire-and-forget.
reportRequestError()now self-registers withctx.waitUntil()via the ALS-backedgetRequestExecutionContext(), matching the existing pattern used byKVCacheHandler, ISR regeneration, and fetch cache revalidationvinext start),getRequestExecutionContext()returnsnull— fire-and-forget remains correct since the process doesn't diereportRequestErrornever rejects (internal try/catch), the redundant.catch()at all 5 call sites across both routers is removedTest plan
registers the report promise with ctx.waitUntil on Workers— verifieswaitUntilis called with the report promise insiderunWithExecutionContextdoes not call waitUntil when no execution context is available— verifies no-op on Node.jspages-router.test.tspasses (166 tests)entry-templates.test.tspasses (12 tests)api-handler.test.tspasses (40 tests)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.