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

safari: infinite loop when hot reloading #3828

Closed
ydnar opened this issue Sep 1, 2018 · 91 comments · Fixed by #9034
Closed

safari: infinite loop when hot reloading #3828

ydnar opened this issue Sep 1, 2018 · 91 comments · Fixed by #9034
Assignees

Comments

@ydnar
Copy link

ydnar commented Sep 1, 2018

Version

v1.4.2 (or latest 2.0.0 pre code)

Steps to reproduce

  1. Launch dev server via yarn dev (HOST=0.0.0.0 nuxt)
  2. Load http://localhost:3000/
  3. Edit code, any code. Watch the nuxt dev server recompile everything.
  4. Reload
  5. HMR fails, triggering rapid reloading of the entire page, forever, until Safari kills the tab for excessive CPU usage.
  6. The only way to test new code is to close the tab and open a new tab to localhost (and re-open dev console).

What is expected ?

Hot reload to work without forcing me to close the tab and open a new tab every time I change a line of code.

What is actually happening?

Browser crushing infinite reload.

This bug report is available on Nuxt community (#c7666)
@ghost ghost added the cmty:bug-report label Sep 1, 2018
@manniL
Copy link
Member

manniL commented Sep 1, 2018

@ydnar Have you tried to remove all page information about localhost in safari? I had similar issues when a service worker stuck.

@aldarund
Copy link

aldarund commented Sep 1, 2018

I have same\similar issue on chrome all time. I have use of nuxt/pwa. And reloading just hangup on some of hot reload and after it page dont load at all no matter if u close tab, open new tab or anything it will just load forever. Only anonymous window helps. Pretty terrible dev experience

@manniL
Copy link
Member

manniL commented Sep 1, 2018

@aldarund See nuxt-community/pwa-module#60 (comment). This should be an issue of pwa-module, not nuxt-core itself.

@ydnar Please ping me if you do not use workbox/pwa-module

@ydnar
Copy link
Author

ydnar commented Sep 4, 2018

@manniL we’re not using pwa-module, just vanilla Nuxt (dev branch).

@manniL manniL reopened this Sep 4, 2018
@Aric-sky
Copy link

Aric-sky commented Sep 13, 2018

I have same\similar issue on chrome all time. I have use of nuxt/pwa. And reloading just hangup on some of hot reload and after it page dont load at all no matter if u close tab, open new tab or anything it will just load forever. Only anonymous window helps. Pretty terrible dev experience

Have you solved this problem? @aldarund

@Norbz
Copy link

Norbz commented Sep 14, 2018

We have the same issue here, some things I tried without any success :

  • Removing the .nuxt folder
  • Completely killing the server and restarting
  • clearing all cookie, localStorage and stuff...
  • reinstalling all node_modules

I am working on MacOS, happens to all browsers, but not all the time. I can sometime works for a few hours before it happens.
I have PWA module installed, but if i record correctly, it happened before I added it to the project (not sure though)

Environment :

  • node v8.11.3
  • npm v5.5.1
  • yarn v1.9.2

Nuxt : v1.4.2
PWA module : v2.5.0

@galvez
Copy link

galvez commented Sep 14, 2018

I have just experienced the same issue - I am investigating it.

@stale stale bot added stale and removed stale labels Oct 31, 2018
@stale stale bot added the stale label Nov 23, 2018
@manniL manniL removed the stale label Nov 23, 2018
@yoyo837
Copy link

yoyo837 commented Nov 30, 2018

Same issue here. (safari only)
I am using safari for the first time today to debug nuxt.js, I found it so late.

default

Edit: Need to have a build error, change file, make a mistake, save file, as you can see that now..

@bovas85

This comment has been minimized.

@manniL

This comment has been minimized.

@smyth64

This comment has been minimized.

@bovas85
Copy link

bovas85 commented Dec 14, 2018

you can see this happening here in Safari
https://antilophia-ttkaqicfap.now.sh/ or something related to it I think

@papakay

This comment has been minimized.

@felixdenoix
Copy link

felixdenoix commented Dec 26, 2018

Same here, fyi it also happends for me on a nextjs project so it may be a webpack related issue!

@sabithpocker
Copy link

sabithpocker commented Dec 29, 2018

Similar issue with nuxt, Safari shows following errors:

[Info] You are running Vue in development mode. (commons.app.js, line 17101)
Make sure to turn on production mode when deploying for production.
See more tips at https://vuejs.org/guide/deployment.html
[Log] [HMR] connected (vendors.app.js, line 1830)
[Log] [HMR] Checking for updates on the server... (vendors.app.js, line 2118)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (3e9ec34fb6b7af1e692e.hot-update.json, line 0)
[Warning] [HMR] Cannot find update (Full reload needed) (vendors.app.js, line 2128)
[Warning] [HMR] (Probably because of restarting the server) (vendors.app.js, line 2129)
[Warning] [HMR] Reloading page (vendors.app.js, line 2219)

screenshot 2018-12-29 at 10 02 08 pm

screenshot 2018-12-29 at 10 09 14 pm

screenshot 2018-12-29 at 10 10 54 pm

@valera-rozuvan
Copy link

valera-rozuvan commented Jan 3, 2019

Started testing my app in Safari Version 12.0.2 (14606.3.4).

"nuxt": "2.3.4", same problem.

This happens when I restart the app, while the app is already open in the browser. Once the server comes up a second time, Safari goes bezerk 😄

Latest Google Chrome & Mozilla Firefox do not experience such an issue.

@manniL manniL added the pending label Jan 5, 2019
@manniL manniL changed the title Hot reload reloads forever safari: infinite loop when hot reloading Jan 5, 2019
@schrockwell
Copy link

schrockwell commented Jan 7, 2019

Also worth noting: a manual refresh does NOT stop the refresh loop, even with clearing the cache (Cmd-Option-R). The window/tab must be completely closed to stop the loop.

I am also experiencing this on mobile Safari on iOS 12.1.2.

@danchristian
Copy link

I get this too, same as above, only killing the tab solves it 😕

@liepaja
Copy link

liepaja commented Jan 17, 2019

In my case the reason was wrong URL of back-end for graphql and axios. It tries to reconnect, but gets 304.

@manniL
Copy link
Member

manniL commented Dec 9, 2020

@valera-rozuvan Probably trying this first.

#3828 (comment)

What finally worked for me was the following in my nuxt.config.js:

{
  build: {
    devMiddleware: {
      headers: {
        'Cache-Control': 'no-store',
        Vary: '*'
      }
    }
  }
}

@horaciosolorio
Copy link

Thank you looks like this solve the issue

@fabiom91
Copy link

@ydnar Have you tried to remove all page information about localhost in safari? I had similar issues when a service worker stuck.

Thanks, just emptying the cache worked for me

@elielr01
Copy link

I was experiencing this bug, and as @fabiom91 mentioned, just emptying the cache fixed my issue.
No code changes required. 👍

Nuxt: 2.14.12
Safari: 14.0.2

kuwiki pushed a commit to kuwiki-project/wiki-nuxt that referenced this issue Jan 31, 2021
@revolter
Copy link

just emptying the cache fixed my issue

Except you have to do this after almost every server restart...

@JeremyJaydan
Copy link

I've been having this issue for the last few days but with chrome while using a cloud ide & a cloudflare tunnel.

The fix for me was to turn on "Development Mode" in cloudflare under "Caching > Configuration > Development Mode" which disables all caching on that side of things.

I assume this bug has something to do with a conflicting cache/header expectation for the dev server.

@blaadje
Copy link

blaadje commented Mar 3, 2021

I don't get why this issue is closed.
The "workaround" has to be manage by us & remove all cache does not seem like a proper solution.
A lot of users are having this issue since a long time, it's getting annoying.

@pi0
Copy link
Member

pi0 commented Mar 3, 2021

Is this issue reproducible without PWA module?

@revolter
Copy link

revolter commented Mar 3, 2021

Is this issue reproducible without PWA module?

Yes. If it helps you debug this issue, it happens for me in this repo: https://github.com/pandicornzombie/website.

@pi0 pi0 reopened this Mar 3, 2021
@pi0 pi0 removed the pending label Mar 22, 2021
@danielroe danielroe self-assigned this Mar 23, 2021
danielroe added a commit that referenced this issue Mar 23, 2021
* fixes reload loop on safari (closes #3828)
@pi0 pi0 closed this as completed in #9034 Mar 23, 2021
@pi0
Copy link
Member

pi0 commented Mar 23, 2021

Issue should be solved in next nightly (nuxt-edge) and nuxt release (via #9034)

@lorenzofiamingo
Copy link

I have this same problem using nuxt+typescript.
I solved this on macOS running this on terminal:
kill $(lsof -ti:3000)

Probably when I suspended from npm run dev (with ctr+z... maybe I had to use directly ctr+c) process on port is not killed by Nuxt. Indeed, when I rerun the command from the same terminal it connect to another port (and all works fine), but if I rerun the command from another terminal tab it attach another process to the port congesting it (and the view flickers).
In any case with that command all works fine, but is a small consolation since now I have multiples Nuxt processes on random ports that I can't kill.

@danielroe
Copy link
Member

@lorenzofiamingo Have you tried with nuxt-edge using the fix that was just merged?

@lorenzofiamingo
Copy link

@danielroe Sorry but I'm a real beginner with nuxt (started an hour ago 😅), so I'm not sure to know how to do that. Anyway for me the problem is solved using ctr+c to kill npm run dev.

@danielroe
Copy link
Member

@lorenzofiamingo Great - glad all is well 😊

@Grawl
Copy link

Grawl commented Dec 17, 2021

Just had the same issue in Quasar Framework. Open project in dev mode in Safari, got infinite reload with and without Web Inspector. I tried also turn on and off cache button in Web Inspector, has no effect.

My app is in SSR + PWA mode.

I tried to disable PWA feature in my app, no effect.

Before, I had infinite reloading in Chrome with closed Web Inspector.

Then I googled it and I'm here. There is no solution for my problem, so I googled further.

I found this: https://stackoverflow.com/a/41936320/766307

Then I changed devtool property to eval-cheap-source-map and problem is gone. Vue Devtools is working.

@carbdias
Copy link

carbdias commented Nov 30, 2023

I have this same issue without using pwa-module, just Nuxt 3 and Vue 3 and Vite, in 2023. I cannot refresh the page without getting an infinite loop in all browsers in Mac, and I always have to close the tab, clean cache and do a crtl+C and relaunch server again to see new results on the web.

How coud I do this in Nuxt config in Nuxt 3 ?

build: {
devMiddleware: {
headers: {
'Cache-Control': 'no-store',
Vary: '*'
}
}
}

@danielroe
Copy link
Member

@carbdias I would suggest opening a new discussion rather than commenting on an issue closed 3 years ago (where it may unfortunately get lost)

@mathix420
Copy link

I've been having this issue for the last few days but with chrome while using a cloud ide & a cloudflare tunnel.

The fix for me was to turn on "Development Mode" in cloudflare under "Caching > Configuration > Development Mode" which disables all caching on that side of things.

I assume this bug has something to do with a conflicting cache/header expectation for the dev server.

In my case this was not an option as my tunnel was defined in a sub domain used by other apps.
I've identified that the issue was also coming from pwa-module, so here is what I did to fix the issue:

  1. Disable cache for the subdomain only using a cache rule: Caching > Cache Rules > Create Rule > (http.host eq "my.sub.domain") > Bypass cache
  2. Redirect PWA manifest to a 404 page: Rules > Transform Rules > Rewrite URL > Create Rule
    • When incoming requests match (http.host eq "my.sub.domain" and starts_with(http.request.uri.path, "/_nuxt/manifest."))
    • Rewrite to > Static _nuxt/404.json

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

Successfully merging a pull request may close this issue.