cloudflare/vinext

Server actions: incorrect error handling (500 instead of 404, error boundary propagation)

已关闭

#1,340 创建于 2026年5月20日

 (1 条评论) (0 个反应) (0 位负责人)TypeScript (371 个派生)github user discovery
adapter-api-e2ehelp wanted

仓库指标

星标
 (8,563 个星标)
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

Several server action error handling behaviors diverge from Next.js:

  1. Apps with no server actions return 500 instead of 404. When triggering a server action on an app that has no server actions defined, Next.js returns 404 with x-nextjs-action-not-found: 1 header. vinext returns 500 (unhandled error).

  2. Error boundary propagation for action responses. Errors from text/plain responses and responses with invalid content types should propagate to error boundaries. This propagation appears broken.

  3. Unrecognized action handling incorrect. When server actions receive unrecognized action IDs, the error response format does not match Next.js expectations.

Expected: 404
Received: 500  // app with no server actions

Expected: error boundary to catch action error
Received: unhandled error

Estimated Impact

~22 test failures across the deploy suite.

Affected Test Suites

  • test/e2e/app-dir/actions/app-action-node-middleware.test.ts (13 failures)
  • test/e2e/app-dir/actions/app-action.test.ts (13 failures)
  • test/e2e/app-dir/actions-unrecognized/actions-unrecognized.test.ts (9 failures)
  • test/e2e/app-dir/no-server-actions/no-server-actions.test.ts (2 failures)

Recommendation

  1. Reproduce first in vinext's own test suite. Add a test that sends a server action request to an app with no actions defined and asserts a 404 response with the x-nextjs-action-not-found: 1 header. Add a test for error boundary propagation. Confirm they fail.

  2. Return 404 for missing actions. When the server action handler cannot find the action ID, return new Response(null, { status: 404, headers: { "x-nextjs-action-not-found": "1" } }) instead of throwing.

  3. Fix error propagation to error boundaries. Study how Next.js serializes action errors for the client-side error boundary mechanism, particularly for text/plain and invalid content-type responses.

贡献者指南