question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HMR does not pick up updates to data

See original GitHub issue

Environment

Running on WSL but have had the same issue in a containerized application…

Tested in latest Firefox and Chrome with identical results.

Nuxt CLI v3.0.0-27288761.d3fb512
RootDir: …
Nuxt project info:

  • Operating System: Linux
  • Node Version: v16.13.0
  • Nuxt Version: 3.0.0-27288761.d3fb512
  • Package Manager: yarn@1.22.17
  • Bundler: Vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://github.com/radusuciu/nuxt3-app

repro

Describe the bug

Updated data is not picked up by HMR. Updating the template is. Data updates are reflected after a full refresh only.

Potentially related to #1036 but I don’t see any errors and it isn’t sporadic - it just doesn’t work even though Vite does seem to pick up the updates judging by the “Vite server built in XXms” logs messages and “[vite] hot updated: /app.vue” output in the console.

Additional context

I have no issues with HMR in nuxt2, nor if I use vite by itself.

Logs

No response

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:21 (9 by maintainers)

github_iconTop GitHub Comments

4reactions
ilya-adnymicscommented, Apr 7, 2022

Ok, @danielroe, your instinct was right after all:

my instinct is that this might be a watcher issue

I kept digging inside @vitejs/plugin-vue and found out that if I add a 100ms sleep inside handleHotUpdate function after file is read, the autoupdates start working. Then I’ve found this issue, and although it mentions Windows (this was also your instinct I guess, since you asked if I have Windows), the fix worked for me in Ubuntu:

// nuxt.config.ts
export default defineNuxtConfig({
  vite: {
    server: {
      watch: {
        usePolling: true,
      },
    },
  },
});

After I set usePolling to true, it started working as expected. Thank you for your help, I guess this can be closed after @radusuciu confirms.

3reactions
pi0commented, Jul 16, 2022

Thanks for sharing reproductions. I can confirm the same issue on WSL2 and also normal Linux servers and windows. HMR only works fine on a macOS laptop with fsevents.

  • ✅ MacOS
  • ❌ Windows
  • ❌ Linux (arm64 and x86)
  • ❌ WSL2

An interesting finding is that native watcher, works but only for one instance. Disabling server [watcher] with ssr: false, client watcher and HMR start to work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack HMR never updates the page - Stack Overflow
The webpack/hot/only-dev-server runtime only updates modules that are hot-replaceable and doesn't do a full reload. If you don't care about full ...
Read more >
HMR API - Vite
This is the client HMR API. For handling HMR update in plugins, see handleHotUpdate. The manual HMR API is primarily intended for framework...
Read more >
A Deep Dive into Hot Module Replacement with Webpack ...
The goal of HMR is to avoid full page reloads. Currently, the application doesn't accept hot updates, because we haven't instructed it to...
Read more >
Hot Module Replacement - webpack
Hot Module Replacement (HMR) exchanges, adds, or removes modules while an application is running ... If a module has no HMR handlers, the...
Read more >
Webpack's Hot Module Replacement Feature Explained
The hot update will be sent to the HMR server, which will send the updates to HMR runtime. HMR runtime will unpack the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found