Skip to content

BUG: <svelte:boundary> not working when error occurs inside #if block (only in production build)Β #15674

@zeroberry

Description

@zeroberry

Describe the bug

When an error occurs inside #if block within an <svelte:boundary>, there is a bug where the remaining elements are not removed and remain visible.
This issue doesn't occur in the development environment but only happens in the production build. (NODE_ENV=production)

<svelte:boundary>
  <div>This should be removed</div>
  {#if true}
    <ErrorComponent />  <!-- This throws an error -->
  {/if}

  {#snippet failed()}
    <div>error boundary</div>
  {/snippet}
</svelte:boundary>

Reproduction

https://stackblitz.com/edit/vitejs-vite-zvok4jqx?file=src%2FApp.svelte
You can reproduce this issue by running:
NODE_ENV=production npm run dev or npm run build && npm run preview

Logs

System Info

System:
  OS: macOS 15.1
  CPU: (14) arm64 Apple M3 Max
  Memory: 2.69 GB / 36.00 GB
  Shell: 5.9 - /bin/zsh
Binaries:
  Node: 22.13.0 - ~/.local/state/fnm_multishells/49337_1743582171802/bin/node
  Yarn: 1.22.22 - ~/.local/state/fnm_multishells/49337_1743582171802/bin/yarn
  npm: 10.9.2 - ~/.local/state/fnm_multishells/49337_1743582171802/bin/npm
  pnpm: 9.15.0 - ~/.local/state/fnm_multishells/49337_1743582171802/bin/pnpm
Browsers:
  Chrome: 134.0.6998.166
  Safari: 18.1
npmPackages:
  svelte: ^5.20.2 => 5.25.6

Severity

annoyance

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