Skip to content

Components that throw during mount doesn't remount after HMR #17679

@samfundev

Description

@samfundev

Describe the bug

If a component throws while being mounted, that would normally be fine because the developer could fix the code and Svelte would remount the component using HMR. But now, even without having async enabled, HMR fails to remount the component. I've bisected this down to #15844. And found a potential fix which I've made a PR for.

Reproduction

The following reproductions are the same except for the version of Svelte and have a line of code that can be toggled on or off to have the component throw when it mounts.

latest (5.50.1): https://www.sveltelab.dev/32149g118o5egv7
pre-async (5.35.7): https://www.sveltelab.dev/3032460y2gelaoq

Reproduction steps:

  1. Mount a component that has been compiled using the hmr compiler option.
  2. Hot reload the component but have the component throw an exception on mount.
  3. Hot reload the component but without an exception during mount.

(this excludes the playground since it doesn't use hmr: true)

Logs

System Info

n/a

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