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

yopass upgrade and browser cache #787

Closed
PiotrIr opened this issue Feb 23, 2021 · 11 comments
Closed

yopass upgrade and browser cache #787

PiotrIr opened this issue Feb 23, 2021 · 11 comments

Comments

@PiotrIr
Copy link

PiotrIr commented Feb 23, 2021

Hi, I just wonder if you could help me please?
I've just upgraded yopass to the latest version and the server is working fine. However I can see my browser (and any other user's to which I've sent password) keeps an old version of the website. If I open it in incognito mode - everything is working fine. I'm sure if I will clean cache on my browser - it will start working, but I can't do it on all browsers to which I used to send passwords. Could you advise how to resolve the issue please?

@jhaals
Copy link
Owner

jhaals commented Feb 24, 2021

Hi @PiotrIr

Sorry to hear you're having issues. Yopass uses the create-react-app template which used to include a serviceWorker which where registered with the earlier versions of yopass. My guess is that there's a service worker still active in the browser for your domain. My hope is that it will unregister after some time when it notices that it's no longer present in the website.

You could try opening the console in a "broken" browser when on your installation of yopass and run

navigator.serviceWorker.getRegistrations().then((registrations) => { console.log('workers', registrations) })

To see if there's a service worker registered

@PiotrIr
Copy link
Author

PiotrIr commented Feb 25, 2021

Hi jhaals,

Thank you for your reply. Looks you are right about worker:

workers Array [ ServiceWorkerRegistration ]
Promise { : "pending" }

Do you know how long it may take for browser to unregister it? It is four days since I upgraded the yopass and still can see Firefox opens old version...

@jhaals
Copy link
Owner

jhaals commented Feb 26, 2021

I don't know how long it takes for it to expire unfortunately.

One workaround could possibly be to add some custom registration logic into to index page.

navigator.serviceWorker.getRegistrations().then(function(registrations) {
 for(let registration of registrations) {
  registration.unregister()
} })

@PiotrIr
Copy link
Author

PiotrIr commented Mar 1, 2021

Hi jhaals,

Will you be able to advise how to do this? I've tried to log in to container bash and getting message:
OCI runtime exec failed: exec failed: container_linux.go:345: starting container process caused "exec: "/bin/bash": stat /bin/bash: no such file or directory": unknown

I'm not good in docker, so any help will be appreciated.

@jhaals
Copy link
Owner

jhaals commented Mar 2, 2021

The website is compiled so you cannot change it inside the Docker container, secondly it's running distroless so there's no bash or sh available :)

The easiest thing you can do is to clone the repository, goto website/public/index.html
and add a script tag like the one below inside the head block and then go back to the root directory that you just cloned and run docker build -t my-custom-build . and after that you can run the docker container normally except that you use my-custom-build instead of jhaals/yopass when executing the docker run command.

<script>
navigator.serviceWorker.getRegistrations().then(function(registrations) {
 for(let registration of registrations) {
  registration.unregister()
} })
</script>

@grobie
Copy link
Contributor

grobie commented Mar 5, 2021

For what it's worth, I've had pulled my hair out about this behavior as well back at SoundCloud. The caching results in the page appearing to load just fine, even when it was actually not accessible (because SoundCloud's yopass installation was originally deployed behind a SSO reverse proxy). It also sometimes resulted in a very broken page, when the base html was still cached, but the translations couldn't be fetched.

I basically have no knowledge about browser service workers, but removing/improving the cache behavior would be rad.

@jhaals
Copy link
Owner

jhaals commented Mar 5, 2021

Thanks for letting me know.
I'll create a patch to unregister this pesky serviceworker automatically today or early next week.
Sorry for the inconvenience of functionality we where not even using.

@jhaals
Copy link
Owner

jhaals commented Mar 7, 2021

So I've just released version 11.1.0 that includes an automatic unregister. I hope that it will make things easier for your @PiotrIr

@jhaals jhaals closed this as completed Mar 7, 2021
@PiotrIr
Copy link
Author

PiotrIr commented Mar 8, 2021

Hi Johan,

Many thanks for this.
Unfortunately in some reason, after I've upgraded the docker container, this still doesn't work and old website displays. Could you help please?

@jhaals
Copy link
Owner

jhaals commented Mar 8, 2021 via email

@PiotrIr
Copy link
Author

PiotrIr commented Mar 8, 2021

Hi Johan,

Yes, when I pressed ctrl+f5 it has indeed removed all version. Sorry, I've expected it will remove the worker service when I just open the website. Thank you for your help.

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

3 participants