Skip to content

Client navigation leaves stale +error.svelte mounted after remote query render error with experimental handleRenderingErrors #15694

Description

@tudor-cel-stan

Describe the bug

I’m using SvelteKit with both kit.experimental.remoteFunctions and kit.experimental.handleRenderingErrors enabled.

When a remote query throws an error(404, ...) during component render on a client-rendered page, the nearest +error.svelte renders as expected for that route. However, after navigating client-side to another route, the failed error UI is not torn down correctly and remains mounted above the next page’s content.

This minimal repro has two routes:

  • / renders a normal home page with a link to /data
  • /data awaits a remote query at the top level of +page.svelte

The remote query throws:

error(404, "There's no data here");

Reproduction

https://github.com/tudor-cel-stan/sveltekit-error-page-navigation-repro

Steps:

  1. bun install
  2. bun run dev
  3. Open /
  4. Click Go to error page
  5. Confirm the error page renders for /data
  6. Click Click this to see the issue
  7. Observe that / renders, but the old error page remains mounted above the home page content

Relevant files in the repro:

  • src/routes/data.remote.ts
  • src/routes/data/+page.svelte
  • src/routes/+error.svelte
  • src/routes/+page.svelte
  • svelte.config.js

Logs

Browser console:
- No especially useful client error is emitted in the repro
- The issue is primarily visible in the rendered DOM: the old `+error.svelte` remains mounted after navigation

Server logs:
- Only the expected 404 caused by the remote query throwing `error(404, "There's no data here")`
- No additional server-side crash or fatal exception

System Info

System:
  OS: macOS 26.3.1
  CPU: (8) arm64 Apple M3
  Memory: 1.24 GB / 16.00 GB
  Shell: 5.9 - /bin/zsh
Binaries:
  Node: 24.13.0 - /Users/tudorcelstan/.nvm/versions/node/v24.13.0/bin/node
  npm: 11.6.2 - /Users/tudorcelstan/.nvm/versions/node/v24.13.0/bin/npm
  pnpm: 10.33.0 - /Users/tudorcelstan/Library/pnpm/pnpm
  bun: 1.3.10 - /Users/tudorcelstan/.bun/bin/bun
Browsers:
  Brave Browser: 145.1.87.190
  Chrome: 146.0.7680.178
  Safari: 26.3.1
npmPackages:
  @sveltejs/adapter-auto: ^7.0.1 => 7.0.1
  @sveltejs/kit: ^2.57.1 => 2.57.1
  @sveltejs/vite-plugin-svelte: ^7.0.0 => 7.0.0
  svelte: ^5.55.2 => 5.55.2
  vite: ^8.0.8 => 8.0.8

Severity

annoyance

Additional Information

Related issues / nearby prior art I found:

I don’t think those exactly match this repro.

What seems distinct here is:

  • the remote query error is caught and rendered
  • client navigation to another route succeeds
  • but the old failed route UI is still left mounted in the page

A full page reload clears the bad state.
A client-side internal navigation does not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions