Skip to content

Remote form functions: errors caught in enhance always return status code 500 #14256

@cnolte

Description

@cnolte

Describe the bug

Hello everyone,

I want to retrieve the error status code 400 from a form remote function. The problem is that when I catch the error in enhance, it has a status of 500 instead of 400. However, when I check Chrome DevTools, I can see that the remote function responds with a 400 status. Is this a bug, or is there another way to access the response status?

Reproduction

I have the following remote function:

export const update = form(async (data) => {
  error(400, 'Some error')
}

In my form I try to get the status code from the error:

<form {...update.enhance(async ({ submit }) => {
    try {
      await submit()
    } catch(err) {
      console.log(err.status) // This logs 500
    }
  })}
>
  <button type="submit">Update</button>
</form>

Logs

System Info

System:
    OS: macOS 15.6
    CPU: (10) arm64 Apple M1 Pro
    Memory: 794.78 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.3.0 - /opt/homebrew/bin/node
    npm: 11.4.2 - /opt/homebrew/bin/npm
    pnpm: 10.12.4 - /opt/homebrew/bin/pnpm
    bun: 1.2.17 - /opt/homebrew/bin/bun
  Browsers:
    Chrome: 139.0.7258.128
    Safari: 18.6
  npmPackages:
    @auth/sveltekit: ^1.10.0 => 1.10.0 
    @eslint/compat: ^1.3.2 => 1.3.2 
    @eslint/js: ^9.33.0 => 9.33.0 
    @inlang/paraglide-js: ^2.2.0 => 2.2.0 
    @playwright/test: ^1.54.2 => 1.54.2 
    @sentry/sveltekit: 10.5.0 => 10.5.0 
    @sveltejs/adapter-node: ^5.3.1 => 5.3.1 
    @sveltejs/kit: ^2.31.1 => 2.31.1 
    @sveltejs/vite-plugin-svelte: ^6.1.2 => 6.1.2 
    @tailwindcss/vite: ^4.1.12 => 4.1.12 
    @types/papaparse: ^5.3.16 => 5.3.16 
    esbuild: ^0.25.9 => 0.25.9 
    eslint: ^9.33.0 => 9.33.0 
    eslint-config-prettier: ^10.1.8 => 10.1.8 
    eslint-plugin-svelte: ^3.11.0 => 3.11.0 
    exceljs: ^4.4.0 => 4.4.0 
    globals: ^16.3.0 => 16.3.0 
    googleapis: ^156.0.0 => 156.0.0 
    msw: ^2.10.5 => 2.10.5 
    noph-ui: ^0.22.5 => 0.22.5 
    papaparse: ^5.5.3 => 5.5.3 
    prettier: ^3.6.2 => 3.6.2 
    prettier-plugin-svelte: ^3.4.0 => 3.4.0 
    prettier-plugin-tailwindcss: ^0.6.14 => 0.6.14 
    svelte: ^5.38.2 => 5.38.2 
    svelte-check: ^4.3.1 => 4.3.1 
    tailwindcss: ^4.1.12 => 4.1.12 
    typescript: ^5.9.2 => 5.9.2 
    typescript-eslint: ^8.39.1 => 8.39.1 
    vite: ^7.1.2 => 7.1.2 
    vitest: ^3.2.4 => 3.2.4 
    zod: ^4.0.17 => 4.0.17

Severity

blocking an upgrade

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions