AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Inline `"Use Server"` Function Fails When Returned From File-Level `"Use Server"` Function

Nested inline server actions inside module-level `"use server"` files are not registered in the server action manifest when the outer action is imported directly by a Client Component, causing `Failed to find Server Action` at runtime. Passing the outer action as a prop from a Server Component works because the server action registration includes nested IDs.

highConfidence 92%Next.jsAffected V16.3.0-Canary.106

Origin Analysis

Next.js's server action manifest collection for direct Client Component imports only registers top-level exported server actions from `"use server"` files. The SWC transform successfully generates hidden exports for nested inline actions, but the build plugin does not include these nested action IDs in the server reference manifest for that module, so the server cannot resolve the action ID sent by the client.
Create a file `app/imported/actions.ts` with `'use server'` at top, export `outer` returning an inner function marked with inline `'use server'`. Import `outer` directly in a Client Component. Call `outer('captured')` to obtain the inner reference, then call the retained function with `'client'`. Observe the server action not found error. Compare with passing `outer` from a Server Component as a prop, which succeeds.

Fixing Code Block

Edge Case Audit

This workaround changes the API contract: `outer` no longer returns a callable function, so any code that expects a function reference must be updated. If the original pattern is required, you must wait for an official Next.js patch or apply a framework-level fix. Rollback is straightforward by reverting to the original actions.ts and client component, but the bug will reappear. The workaround is safe for production as it uses only supported server action forms.

Ecosystem Topology