Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
zeroberry opened this issue Apr 3, 2025 · 1 comment · Fixed by #15793

Comments

@zeroberry
Copy link
Contributor

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

@minkky
Copy link

minkky commented Apr 3, 2025

Could this issue be related to this line?

@zeroberry zeroberry changed the title Content persists in <svelte:boundary> when error occurs in #if block (on production only) BUG: <svelte:boundary> not working when error occurs inside #if block (only in production build) Apr 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants