Skip to content

Svelte boundary doesn't catch form error #14888

@timootten

Description

@timootten

Describe the bug

This is my code:

+page.svelte

<script lang="ts">
    import { runTest } from './test.remote';
</script>

<h1>Landing Page</h1>

<svelte:boundary>
    {#snippet pending()}
        <p>Pending</p>
    {/snippet}
    {#snippet failed(error, reset)}
        <p class="text-red-600">Failed to runTest</p>
        <p class="text-red-600">Error message: {error}</p>
        <button onclick={reset}>Try Again</button>
    {/snippet}

    <form {...runTest}><button type="submit">runTest</button></form>
</svelte:boundary>

test.remote.ts

import { form } from "$app/server";
import { error } from "@sveltejs/kit";

export const runTest = form(async () => {
  error(500, "This is a test error from test.remote.ts");
});

Result is in the images, it only displays:

500
This is a test error from test.remote.ts
Image Image

Reproduction

https://github.com/timootten/SvelteKit-Form-Error

Logs

  VITE v7.2.0  ready in 1548 ms

  ➜  Local:   http://localhost:5174/
  ➜  Network: use --host to expose
  ➜  press h + enter to show help

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (16) x64 AMD Ryzen 7 5700X 8-Core Processor
    Memory: 14.07 GB / 31.91 GB
  Binaries:
    Node: 22.20.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.9.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: 10.18.1 - C:\Users\timoo\AppData\Local\pnpm\pnpm.CMD
    bun: 1.3.1 - C:\Users\timoo\AppData\Local\pnpm\bun.CMD
    Deno: 2.3.3 - C:\Users\timoo\.deno\bin\deno.EXE
  Browsers:
    Chrome: 141.0.7390.123
    Edge: Chromium (140.0.3485.54)
    Firefox: 144.0.2 - C:\Program Files\Mozilla Firefox\firefox.exe
    Internet Explorer: 11.0.26100.1882
  npmPackages:
    @sveltejs/adapter-node: ^5.3.2 => 5.4.0
    @sveltejs/kit: ^2.43.2 => 2.48.4
    @sveltejs/vite-plugin-svelte: ^6.2.0 => 6.2.1
    svelte: ^5.39.5 => 5.43.3
    vite: ^7.1.7 => 7.2.0

Severity

blocking an upgrade

Additional Information

No response

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