Skip to content

New component initializes before destroying old component since 5.36.0 #16753

@jirihon

Description

@jirihon

Describe the bug

Before 5.36.0, when switching two components, the initialization of the new component executed after the onDestroy callback of the old component.

Since 5.36.0, the initialization of the new component runs before the onDestroy callback of the old component. See the console output of the REPL.

This is unexpected. Why was it changed? If it is intended, could it be, please, documented in https://svelte.dev/docs/svelte/lifecycle-hooks?

This issue may be just a simpler reproduction of #16618.

Reproduction

https://svelte.dev/playground/82d317baba1e4ef19cb44e79bbef836e?version=5.38.9

Logs

System Info

System:
    OS: Linux 6.8 Ubuntu 22.04.5 LTS 22.04.5 LTS (Jammy Jellyfish)
    CPU: (16) x64 AMD Ryzen 7 PRO 6850U with Radeon Graphics
    Memory: 18.69 GB / 30.12 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 20.12.2 - ~/.nvm/versions/node/v20.12.2/bin/node
    Yarn: 4.9.1 - ~/.nvm/versions/node/v20.12.2/bin/yarn
    npm: 10.5.0 - ~/.nvm/versions/node/v20.12.2/bin/npm
    bun: 1.2.16 - ~/Projekty/Planner/designer/node_modules/.bin/bun
  Browsers:
    Chrome: 140.0.7339.127
  npmPackages:
    svelte: ^5.37.2 => 5.37.2

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