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

Bug with Safari #1132

Closed
shammelburg opened this issue Apr 14, 2018 · 33 comments
Closed

Bug with Safari #1132

shammelburg opened this issue Apr 14, 2018 · 33 comments

Comments

@shammelburg
Copy link

Version

3.0.0-beta.6

Reproduction link

https://github.com/shammelburg/vue-cli-test

Steps to reproduce

Once you've cloned the project,

  1. npm run serve
  2. Go to Input.vue
  3. add another input in the template
  4. save (this will show on hot reload)
  5. refresh the browser manually (the input is gone)
  6. return to the code and save the file again (input appears)

What is expected?

When I refresh the browser the app needs to give me the latest build from when I saved the changes.

What is actually happening?

When making changes to a .vue file, eg. changing an input in the template,

the browser updates initially but when you refresh the browser manually it seems to return to first time you run 'npm run serve'.

When starting and stopping the app through terminal the app runs ok.

A similar things happens when changing property names.


I've ran this on Chrome and it works fine.

I'm running this on my Mac.

@zigomir
Copy link
Contributor

zigomir commented Apr 14, 2018

So weird. It doesn't have to do anything with input, it behaves same for anything you change. Hot reload works, but after refresh you get old contents. I figured if I refresh http://localhost:8080/app.js in another tab I get latest bundle served and manual refresh works again. But not always 🌘 Even disabling cache (see Safari 11.1 below) won't help :/

It looks like Safari 11.1 caching issue to me. My wild guess would be they introduced regressions with implementing service workers. 👹

@daniele-orlando
Copy link

daniele-orlando commented Apr 20, 2018

I'm facing the same bug.
Vue-Cli 3.0.0-beta.6
Safari 11.1

It is such a problem that I can't use Safari to develop with Vue anymore.

@yyx990803
Copy link
Member

This is definitely a bug in Safari itself...

@joshgoebel
Copy link

FYI: Confirming issue with Safari 11.1.2. Also Safari Tech Preview Release 60 (Safari 12.0, WebKit 13606.1.23.1).

Works fine in Chrome.

@Twinpix
Copy link

Twinpix commented Aug 2, 2018

I was facing the same annoying bug with Safari (both desktop and mobile), and since "app.js" was not updated , I had to add this code in "vue.config.js" to make it work.

module.exports = {
  chainWebpack: config => {
    if (process.env.NODE_ENV === 'development') {
      config
        .output
        .filename('[name].[hash].js') 
        .end() 
    }  
  }
}

@lmuzquiz
Copy link

Same issue here using safari 13.0.4 on Mac OS Catalina 10.15.2

@iandk
Copy link

iandk commented Jan 24, 2020

Same issue

@patricklewis
Copy link
Contributor

Same issue here, Safari 13.0.4 on macOS 10.15.2 and Safari hot-reloads correctly on file changes but then reverts back to an older version of the site upon a refresh.

@rskvazh
Copy link

rskvazh commented May 9, 2020

Same issue with Safari 13.1 (and older too) and vue serve. "Hot reload" reloads code successfully, but when I refresh page (Cmd+R) - old result loading unless I close the tab and open this same URL. In Network tab caching is off.

@chrisbartow
Copy link

First day using Vue and ran into this issue with Safari 13.1.1 trying to update the Hello World project and nothing changes.

@adarshsrivastava11
Copy link

Same issue with Safari 13.1 (and older too) and vue serve. "Hot reload" reloads code successfully, but when I refresh page (Cmd+R) - old result loading unless I close the tab and open this same URL. In Network tab caching is off.

@rskvazh @chrisbartow It is not a bug, Safari caching engine works differently and is currently in not in sync with how vue-loader works, so it'll always cache the first version and keep it persistent. You can change this behaviour in the developers tools. But I'd advices to use chrome or use Safari's incognito mode.

danfishgold added a commit to danfishgold/wikipedia-charts that referenced this issue Oct 6, 2020
There's a problem with the cache. it's a whole thing
(vuejs/vue-cli#1132)
@cvn
Copy link

cvn commented Nov 28, 2020

This is still an issue as of Safari 14.0.1 and vue-cli 4.5.9.

I filed a WebKit bug report https://bugs.webkit.org/show_bug.cgi?id=219323.

In the meantime, I clear the cache before each reload.

  1. Clear the cache with: ⌘ Command + ⌥ Option + E
  2. Refresh the page: ⌘ Command + R

Thanks to @bfanger for this tip.

P.S. @Twinpix's workaround is an alternative to clearing the cache before every reload, but apparently it can cause a memory leak. Adding the hash to the query string instead of the file name is another option, but can cause issues with some webpack loaders. See commits 33dad39, 52dbdf8, and 0909bc8.

@panderson1000
Copy link

Unfortunately this is making me think twice about using Vue. Just rebuilt my site with VueJS 3 and after deployment discovered Safari is choking. desktop Chrome OK, mobile Chrome OK, mobile Safari OK, desktop Safari NOPE! See alot of timeouts BUT ONLY on Safari.

@cvn
Copy link

cvn commented Dec 10, 2020

@panderson1000 This bug is limited to an issue with local development using vue-cli. It does not affect deployed code. Perhaps you can post on the vue forum https://forum.vuejs.org with your issue.

@FakieKickflip
Copy link

First day with vue and still got this error with safari version 14.0.3. Kinda annoying to clear the cache before reload.

@herrernst
Copy link

@FakieKickflip You should better report this bug to Apple and insist on fixing it as this is a problem with Safari and not with Vue CLI.

@kertahayu
Copy link

I believe this is not a problem in safari, I developed several applications that use webpack and run normally.

maybe vue doesn't fully support safari by default.

this comment is at least helpful #1132 (comment)

@crypthonics
Copy link

This issue still persists on v14.1. Since this is caching related, I don't think it will ever get "fixed" because of different caching methods of Safari, so there is nothing to fix from Safari's side. Emptying the caches and reloading works, but since the deployed code doesn't cause problems, I would suggest to use another browser for active development and just do a final check with Safari when the developed feature is finished.

@talmobi
Copy link

talmobi commented Jun 4, 2021

Still an issue.

Clearing cache does NOT necessarily fix this issue. As crazy as that sounds. I think it may possibly be Service Worker related and here's what's happening.

Even destroying the development/localhost tab and creating a new one may not necessarily work. The first page you get served might be the correct updated one. But after you interact with the page or trigger a hot reload update, the page will REVERT BACK to an old version. This is crazy behaviour. I'm not exactly sure why or how but it smells like Service Worker related to me.

Things that will not work:

  • restarting web pack dev server
  • clearing cache on Safari
  • destroying the localhost tab and opening a new one

The above may work temporarily, but if you interact or issue a HMR update after loading, the page CAN REVERT BACK to an older version.

I found this out after having a console.log on a mounted on a component. And after having removed the console.log from the code. The old console.log message would appear from time to time (including old behaviour) even after all the above things. Restarting dev server, clearing cache, opening a new tab.

On Chrome at the same time everything was working fine, I was served the most updated version.

I'm not exactly sure what's going on but seems like possibly Service Worker related?

Safari Version 14.0.3 (16610.4.3.1.7)
Chrome Version 91.0.4472.77 (Official Build) (arm64)
OSX 11.2.3 (20D91)
MacBook Pro (13-inch, M1, 2020), M1, 16GB

node v14.16.0
npm 6.14.11
yarn 1.22.10

vue 2
@vue/cli-service 4.4.6

@rx2347
Copy link

rx2347 commented Jun 4, 2021

Same thing on Safari 14.1 (15611.1.21.161.7, 15611) on Catalina 10.15.7 and Vue CLI 4.5.12

Quite annoying.

@nuvallo
Copy link

nuvallo commented Jun 16, 2021

I am having the same issue with my m1 8g Macbook Pro. If I clear the cache I will see my new changes but pretty annoying to have to keep clearing the cache for each save or change.

@bfanger
Copy link

bfanger commented Jun 17, 2021

There is nothing the vue-cli team can do, it's a bug in Safari: https://bugs.webkit.org/show_bug.cgi?id=219323
Even adding a Cache-Control: no-store, max-age=0 to the response has no effect and the result is still cached (Safari 14.1.1)

It's sad, but Safari simply doesn't comply with the http spec and also disregards the disable-cache devtool setting.

Instead of commenting in this thread, report the issue in channels that are read by the Safari browser developers/dev-advocates.

@talmobi
Copy link

talmobi commented Jun 17, 2021

@bfanger Why does this only happen with Vue on Safari? And not with any other devtool?

@greenuns
Copy link

greenuns commented Jun 19, 2021

i have the same issue. I thought my css wasn't working on mobile only to find out it's a vue bug.
For me it's on iPhone and iPad Safari AND Chrome.
The only way to get it work is to not refresh at all and by any chance I refreshed, I would need to close the tab and reopen.
Desktop is fine as I refresh with CMD+Shift+R.

@vue/cli 4.5.13
iOS version: 14.6
iOS Safari version: assuming Safari 14
iOS Chrome version: 91.0.4472.80
iPhone 7

@andrecp
Copy link

andrecp commented Jul 26, 2021

+1, it's a quite frustrating first user experience with the project.

@D1kz
Copy link

D1kz commented Jul 27, 2021

+1
still having this issue with Safari 14.1.2

@agileben
Copy link

Yeah ran into this today with Safari 14.1.2 (16611.3.10.1.3)

@ctstewart
Copy link

Same issue, I'm on Safari 14.1.1

@musakanneh
Copy link

I was facing the same annoying bug with Safari (both desktop and mobile), and since "app.js" was not updated , I had to add this code in "vue.config.js" to make it work.

module.exports = {
  chainWebpack: config => {
    if (process.env.NODE_ENV === 'development') {
      config
        .output
        .filename('[name].[hash].js') 
        .end() 
    }  
  }
}

Thanks for this, mate/

@speg
Copy link

speg commented Oct 5, 2021

@Twinpix config to chainWebpack seems to do the trick. Is there any downside? If no, can this be adopted into the project defaults?

Update: so it seemed to work, but then it happened again a bit later so perhaps this isn't a rock solid solution.

@cvn
Copy link

cvn commented Oct 6, 2021

Hi, @speg. They already tried it and ran into issues, so they reverted it. See my comment above #1132 (comment) for a list of commits if you're curious about the details.

@evvvritt
Copy link

This comment's config was no longer working for me so I added chunkFilenames hashing and seems to be busting properly now in Safari 15.4

chainWebpack: config => {
    if (process.env.NODE_ENV === 'development') {
      config
        .output
        .filename('[name].[hash].js')
        .chunkFilename('[name].[hash].js')
        .end()
    }
},

@jared201
Copy link

jared201 commented Feb 2, 2023

This comment's config was no longer working for me so I added chunkFilenames hashing and seems to be busting properly now in Safari 15.4

chainWebpack: config => {
    if (process.env.NODE_ENV === 'development') {
      config
        .output
        .filename('[name].[hash].js')
        .chunkFilename('[name].[hash].js')
        .end()
    }
},

This fixed my problem today

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

No branches or pull requests