Skip to content

Remote function errors don't render +error routes during SSR #14398

@madeleineostoja

Description

@madeleineostoja

Describe the bug

HTTP errors thrown in remote functions (using the error() helper) are not handled consistently between client rendering and SSR. If a remote function throws an HTTP error during SSR (eg: when called in a +page.server.ts) the appropriate +error.svelte route isn't rendered, triggering the static HTML fallback error page instead.

If you disable SSR, and trigger the same error, the appropriate error boundary/route is used, as if the error occurred in the caller. I believe this is the correct behaviour, or at least I hope it is, because it makes remote functions far more usable.

I originally thought this was intended behaviour and added my voice to this request/issue, but seeing the discrepancy with SSR leads me to believe this is actually a bug.

Worth noting I don't have async Svelte enabled, so I don't think there should be interactions with the SSR limitations that carries.

Reproduction

Code Repro
https://stackblitz.com/edit/sveltejs-kit-template-default-7neh1jev?file=src%2Froutes%2F%2Bpage.js

  1. Comment out ssr disabling line
  2. Observe issue

Detailed Rerpo

  1. Throw an HTTP error in a remote function, using the error() helper
  2. Add a +error.svelte boundary to your app
  3. Call the remote function in a route
  4. Observe the fallback error page getting rendered rather than your error route
  5. Disable SSR
  6. Trigger the error again, observe the error route getting rendered

Logs

System Info

System:
    OS: macOS 15.5
    CPU: (8) arm64 Apple M1
    Memory: 153.86 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.5.0 - /usr/local/bin/node
    npm: 9.2.0 - /opt/homebrew/bin/npm
  Browsers:
    Chrome: 139.0.7258.155
    Firefox: 109.0.1
    Safari: 18.5
  npmPackages:
    svelte: ^5.38.1 => 5.38.1 
    vite: ^7.1.2 => 7.1.2

Severity

blocking an upgrade

Additional Information

This issue is blocking my usage of remote functions in an SSR app, forcing me to either disable SSR (not tenable for this app, SEO matters) or refactor my new remote functions back into dupllicated load function logic

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions