Server actions: incorrect error handling (500 instead of 404, error boundary propagation)
#1,340 opened on 2026/05/20
Repository metrics
- Stars
- (8,563 個のスター)
- PR merge metrics
- (平均マージ 1d 1h) (30d で 462 merged PRs)
説明
This issue was created by an agent analysing CI failures from the Next.js Deploy Suite (vinext
mainvs Next.jsv16.2.6, 2026-05-20).
Problem
Several server action error handling behaviors diverge from Next.js:
-
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: 1header. vinext returns 500 (unhandled error). -
Error boundary propagation for action responses. Errors from
text/plainresponses and responses with invalid content types should propagate to error boundaries. This propagation appears broken. -
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
-
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: 1header. Add a test for error boundary propagation. Confirm they fail. -
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. -
Fix error propagation to error boundaries. Study how Next.js serializes action errors for the client-side error boundary mechanism, particularly for
text/plainand invalid content-type responses.