Skip to content

createServerFn not propagating error #2577

@hahnrobert

Description

@hahnrobert

Which project does this relate to?

Start

Describe the bug

export const some_fn = createServerFn("POST", async (_) => {
  throw new Error("always throw");
});

const mutation = useMutation({
        mutationFn: some_fn,
        onError: (error) => {
            console.log(error)
        }
})

<button onClick={() => mutation.mutate()}>click me</button>

The POST request returns a 200 and no error is returned in the network request or logged by the client in any other way.

Your Example Website or App

N/A

Steps to Reproduce the Bug or Issue

See code above

Expected behavior

The onError function is called accordingly.

Screenshots or Videos

No response

Platform

  • OS: macOS
  • Browser: Chrome
  • Version:
    "@tanstack/eslint-plugin-query": "^5.59.7",
    "@tanstack/react-form": "^0.34.0",
    "@tanstack/react-query": "^5.59.15",
    "@tanstack/react-query-devtools": "^5.59.15",
    "@tanstack/react-router": "^1.33.2",
    "@tanstack/react-router-with-query": "^1.70.1",
    "@tanstack/router-devtools": "^1.33.2",
    "@tanstack/router-vite-plugin": "^1.32.17",
    "@tanstack/router-zod-adapter": "^1.70.1",
    "@tanstack/start": "^1.70.0",
    "@tanstack/zod-form-adapter": "^0.34.0",

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    startEverything about TanStack Start

    Type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions