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

HMR double prints with and without a leading / #13138

Open
1 task done
taep96 opened this issue Feb 4, 2025 · 2 comments
Open
1 task done

HMR double prints with and without a leading / #13138

taep96 opened this issue Feb 4, 2025 · 2 comments
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) feat: hmr Related to HMR (scope)

Comments

@taep96
Copy link

taep96 commented Feb 4, 2025

Astro Info

Astro                    v5.2.5
Node                     v23.7.0
System                   Linux (x64)
Package Manager          bun
Output                   static
Adapter                  none
Integrations             @astrojs/solid-js

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

HMR double prints with and without a leading /, possibly running other things twice?
Image

What's the expected result?

Only printing the update once.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-7i7skwn6?file=src%2Fpages%2Fhello.tsx

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Feb 4, 2025
@aalfiann
Copy link

aalfiann commented Feb 5, 2025

I got the same problem,

I just upgrade to version 5.2.3.

Image

Everytime I've updated the code, it's render twice.

The problem is when I use custom-element

class SectionBannerList extends HTMLElement {
    connectedCallback() {
        const name = this.dataset.name;
        if(name) {
            // I have to check if name is not empty, cause its rendering twice.
            // FYI, the first name is not undefined, but the second render is undefined.
        }
    }
}

@ematipico ematipico added - P3: minor bug An edge case that only affects very specific usage (priority) feat: hmr Related to HMR (scope) labels Feb 6, 2025
@florian-lefebvre florian-lefebvre removed the needs triage Issue needs to be triaged label Feb 7, 2025
@TheOtterlord
Copy link
Member

Looks like this is caused by Vite running HMR across environments in parallel. An update is caused by the first environment, before the second environment causes a page reload.
https://github.com/vitejs/vite/blob/71227be9aab52c1c5df59afba4539646204eff74/packages/vite/src/node/server/hmr.ts#L617

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) feat: hmr Related to HMR (scope)
Projects
None yet
Development

No branches or pull requests

5 participants