Skip to content

nextAppDirCaller reports the previous state to onError instead of the submitted input #8050

Closed

Description

@LittleChenLiya

nextAppDirCaller picks the real input per procedure type, but onError ignores it and reports opts.args[0].

With useActionState / useFormState, the action is called as (prevState, formData), so onError reports the previous state instead of what was submitted. A single FormData argument is also reported raw, while the procedure receives the normalized object.

Repro:

const proc = t.procedure
  .experimental_caller(nextAppDirCaller({ onError: ({ input }) => log(input) }))
  .mutation(() => {
    throw new Error('boom');
  });

const formData = new FormData();
formData.set('name', 'Ada');
await proc({ name: 'stale' }, formData);

log prints { name: 'stale' }. It should print { name: 'Ada' }, the value the procedure received.

Cause: packages/server/src/adapters/next-app-dir/nextAppDirCaller.ts computes input in each branch and passes it to invoke(), but handleError reads opts.args[0].

Versions: @trpc/server 11.x, Next 15/16.

Activity

  1. added a commit that references this issue on Nov 14, 2026
    1052635
  2. github-actions commented on Nov 15, 2026

    @github-actions
    Contributor

    This issue has been locked because we are very unlikely to see comments on closed issues. If you are running into a similar issue, please create a new issue. Thank you.

  3. locked as resolved and limited conversation to collaborators on Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions