cloudflare/vinext

`next/after` API (`waitUntil`) not working in deploy mode

已關閉

#1,365 建立於 2026年5月20日

 (1 則留言) (0 個反應) (0 位負責人)TypeScript (383 個分叉)github user discovery
adapter-api-e2ehelp wanted

倉庫指標

星標
 (8,624 顆星)
PR 合併指標
 (平均合併 1天 1小時) (30 天內合併 462 個 PR)

描述

This issue was created by an agent analysing CI failures from the Next.js Deploy Suite (vinext main vs Next.js v16.2.6, 2026-05-20).

Problem

The next/after API (which allows running code after the response has been sent, similar to waitUntil) does not appear to function correctly in deploy mode. Tests for next-after-app-deploy fail, suggesting the after callbacks either do not execute or their effects are not observable.

The after() function is used for tasks like logging, analytics, and cache warming that should not delay the response.

Estimated Impact

~6 test failures.

Affected Test Suites

  • test/e2e/app-dir/next-after-app-deploy/index.test.ts (6 failures)

Recommendation

  1. Reproduce first in vinext's own test suite. Add a test that calls after() in a server component or route handler and verifies the callback executes after the response is sent. Confirm it fails in deploy/production mode.

  2. Study the Next.js after implementation. Search .nextjs-ref/packages/next/src/server/ for the after API to understand how it hooks into the response lifecycle.

  3. Map to Cloudflare Workers waitUntil. On Cloudflare Workers, after() should map to ctx.waitUntil() from the execution context. Ensure the execution context is available in the server entry and that after() callbacks are properly registered.

  4. Check dev/prod parity. The after() API may work in dev mode but fail in production if the execution context is not wired through correctly.

貢獻者指南