Skip to content
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

🐛 BUG: Svelte if statements break after HMR #3566

Closed
1 task
bholmesdev opened this issue Jun 9, 2022 · 1 comment · Fixed by #3932
Closed
1 task

🐛 BUG: Svelte if statements break after HMR #3566

bholmesdev opened this issue Jun 9, 2022 · 1 comment · Fixed by #3932
Assignees
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) feat: hmr Related to HMR (scope)

Comments

@bholmesdev
Copy link
Contributor

bholmesdev commented Jun 9, 2022

What version of astro are you using?

1.0.0-beta.42

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

npm

What operating system are you using?

Mac, Windows

Describe the Bug

When using a Svelte conditional based on a state variable:

<script>
let count = 0
</script>

{#if count % 2 === 0}
<p>It's even!</p>
{/if}

...changes to any file in the dev server (including the astro template rendering the component) will break hydration. See the error message below from the clientside console:

Uncaught (in promise) TypeError: Cannot read properties of null (reading 'removeChild')
    at detach (chunk-4S6C63PG.js?v=86714e0a:321:19)
    at detach_dev (chunk-4S6C63PG.js?v=86714e0a:1809:3)
    at Object.destroy [as d] (Wrapper.svelte? [sm]:16:32)
    at Object.destroy [as d] (Content.svelte? [sm]:2:38)
    at chunk-4S6C63PG.js?v=86714e0a:1019:17
    at run (chunk-4S6C63PG.js?v=86714e0a:19:10)
    at Array.forEach (<anonymous>)
    at run_all (chunk-4S6C63PG.js?v=86714e0a:25:7)
    at check_outros (chunk-4S6C63PG.js?v=86714e0a:1000:5)
    at Object.update [as p] (Content.svelte? [sm]:7:22)

A page refresh fixes this.

Note: To see the error in the example linked below:

  1. make an edit to the index.astro file
  2. save
  3. click the button in the preview

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-uqfwdr-jnpvhj?file=src/pages/index.astro

  • does not break production builds
  • bumping back to beta.37 fixes the issue

Participation

  • I am willing to submit a pull request for this issue.
@bholmesdev bholmesdev added - P5: urgent Fix build-breaking bugs affecting most users, should be released ASAP (priority) s2-medium labels Jun 9, 2022
@caioferrarezi
Copy link
Contributor

caioferrarezi commented Jun 10, 2022

Just a little comment, we had this error in production in a component with a await statement, but I couldn't reproduce this in stackblitz yet.

@natemoo-re natemoo-re assigned bholmesdev and unassigned natemoo-re Jun 22, 2022
@FredKSchott FredKSchott added - P4: important Violate documented behavior or significantly impacts performance (priority) and removed - P5: urgent Fix build-breaking bugs affecting most users, should be released ASAP (priority) labels Jul 6, 2022
@FredKSchott FredKSchott added the feat: hmr Related to HMR (scope) label Jul 7, 2022
@natemoo-re natemoo-re linked a pull request Jul 20, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) feat: hmr Related to HMR (scope)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants