Skip to content

Bug: HMR stops working on child component after updating parent #1320

Description

@mwojick

Describe the bug

See reproduction steps below. I tested it on the current latest versions (Vite 8 and vite-plugin-svelte 7 with Svelte 5.55), but also reproduced with Vite 7 and vite-plugin-svelte 5 and 6, so this doesn't seem to be a recent issue.

Reproduction URL

https://github.com/mwojick/svelte-vite-hmr-bug

Reproduction

  1. Scaffold a Svelte project (TS or JS) with Vite: pnpm create vite, or use the linked repro, it's the same thing. Start dev server with pnpm run dev
  2. Change some text in Counter.svelte -> see UI update
  3. Change some text in App.svelte -> see UI update
  4. Change some text again in Counter.svelte -> no longer see a UI update, but there is a [vite] hot updated: /src/lib/Counter.svelte in the dev console, so Vite is doing something, but it seems like it's trying to update a stale version of Counter that is no longer in the UI. Because when you change App again, the change to Counter finally shows up.

Logs

System Info

System:
    OS: Linux 6.6 Ubuntu 24.04.2 LTS 24.04.2 LTS (Noble Numbat)
    CPU: (24) x64 AMD Ryzen AI 9 HX 370 w/ Radeon 890M
    Memory: 13.46 GB / 15.18 GB
    Container: Yes
    Shell: 5.9 - /home/mwojick/.nix-profile/bin/zsh
  Binaries:
    Node: 24.14.0 - /home/mwojick/.nix-profile/bin/node
    Yarn: 4.13.0 - /home/mwojick/.nix-profile/bin/yarn
    npm: 11.9.0 - /home/mwojick/.nix-profile/bin/npm
    pnpm: 10.33.0 - /home/mwojick/.nix-profile/bin/pnpm
    bun: 1.3.11 - /home/mwojick/.nix-profile/bin/bun
  npmPackages:
    @sveltejs/vite-plugin-svelte: ^7.0.0 => 7.0.0
    svelte: ^5.55.1 => 5.55.3
    vite: ^8.0.4 => 8.0.8

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions