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

Cache (weird) bug on Firefox #3842

Closed
roiLeo opened this issue Aug 26, 2022 · 16 comments · Fixed by #4032
Closed

Cache (weird) bug on Firefox #3842

roiLeo opened this issue Aug 26, 2022 · 16 comments · Fixed by #4032

Comments

@roiLeo
Copy link
Contributor

roiLeo commented Aug 26, 2022

Looks like an old version of https://github.com/kodadot/packages/tree/main/sub-api
Tested both on: https://beta.kodadot.xyz/

Firefox

Capture d’écran 2022-08-26 à 2 42 03 PM

console

[KODADOT::SUBAPI] LOG: Api already connected at wss://rpc-01.basilisk.hydradx.io
api.isConnected? 💀

Chrome

Capture d’écran 2022-08-26 à 2 43 17 PM

console

[KODADOT::SUBAPI] LOG: Api already connected at wss://basilisk-kodadot.hydration.cloud
api.isConnected? 💚

any idea where this bug come from? I clear my cache everytime on firefox.

@roiLeo
Copy link
Contributor Author

roiLeo commented Aug 26, 2022

nvm worked after clearing indexDb & cookies

@roiLeo roiLeo closed this as completed Aug 26, 2022
@yangwao
Copy link
Member

yangwao commented Aug 26, 2022

had same in chrome back in July even after updates!

👀

@roiLeo
Copy link
Contributor Author

roiLeo commented Aug 29, 2022

Capture d’écran 2022-08-29 à 3 27 19 PM

And again! (on beta) I don't see "New version" notification :(

@roiLeo roiLeo reopened this Aug 29, 2022
@yangwao
Copy link
Member

yangwao commented Aug 29, 2022

Maybe this did not worked as anticipated?

@preschian
Copy link
Member

preschian commented Aug 29, 2022

Maybe this did not worked as anticipated?

I think so 🤔

I found this one GoogleChrome/workbox#3060
even the workbox does not work properly on firefox. step 5 and 6 not working in firefox on this demo https://glitch.com/~workbox-core

IndexedDB and workbox only partial support on firefox

@petersopko
Copy link
Contributor

I've just closed "Close to update" popup and got this, maybe some unrelated fluke, but still weird:
image
image

@preschian
Copy link
Member

preschian commented Aug 30, 2022

I've just closed "Close to update" popup and got this, maybe some unrelated fluke, but still weird: image image

ah, I got this error also yesterday on Chrome. but I don't know how to reproduce it. same error regarding PostgreSQL: No space left on device

aahh, I just got that error again recently
Screen Shot 2022-08-30 at 18 03 25

@yangwao
Copy link
Member

yangwao commented Aug 30, 2022

I've asked SubSquid about PostgreSQL error; I've already seen that one long time ago.

@yangwao yangwao changed the title weird bug on firefox Cache (weird) bug on Firefox Aug 30, 2022
@preschian
Copy link
Member

just some thoughts

And again! (on beta) I don't see "New version" notification :(

for this case, who triggering the notification is from the workbox

but even if the user sees the notification, currently flush indexedDB does not work on firefox. because in this PR #3834 using indexedDB.databases(), I just realized it didn't work on firefox. source: https://developer.mozilla.org/en-US/docs/Web/API/IDBFactory/databases. quick fix, no need to use indexedDB.databases(). just use indexedDB.deleteDatabase("db-name") instead

after some research, I have some points to address this issue

  1. I personally prefer to prioritize this issue Explore other fast IPFS gateways #3745 and then drop indexedDB support.
  2. But, if we still want to use indexedDB. I think we need to revisit the cache mechanism. maybe, put the date also in the key. the goal is to auto-revalidate for the user. in case workbox is not triggering, indexedDB is still revalidated.

code example for no.2:

// by default, put the date when storing data to indexedDB
setCache('hash', data)
// will be stored like this
// key: 'hash-2022-01-20'
// value: data

// today = 2022-01-20
// find cache with key 'hash-2022-01-20'
getCache('hash') // match

// today = 2022-01-21
// find cache with key 'hash-2022-01-21'
getCache('hash') // doesn't exist

by default, the cache only validates for 1 day. how to set cache for n days

// to set cache for 3 days
setCache('hash', data, { total: 3 })
// will be stored 3 times
// key: 'hash-2022-01-20'
// key: 'hash-2022-01-21'
// key: 'hash-2022-01-22'

how to set cache for n months

// set cache for 1 month
setCache('hash', data, { unit: 'month' })
// store cache with
// key: 'hash-2022-01'

// today = 2022-01-09
// find cache with key 'hash-2022-01'
getCache('hash', 'month') // match

// set cache for 3 months
setCache('hash', data, { total: 3, unit: 'month' })
// store multiple  cache
// key: 'hash-2022-01'
// key: 'hash-2022-02'
// key: 'hash-2022-03'

but still, I personally prefer point 1

@roiLeo
Copy link
Contributor Author

roiLeo commented Aug 31, 2022

any js command to hack/clear idb? I've encountered a new 🐛

Capture d’écran 2022-08-31 à 3 22 17 PM

@preschian
Copy link
Member

any js command to hack/clear idb? I've encountered a new 🐛

maybe try this one window.indexedDB.deleteDatabase('db-name')

when developing on Chrome, I click this Clear site data button. maybe firefox has this panel also
Screen Shot 2022-09-01 at 17 17 38

@petersopko
Copy link
Contributor

I've just closed "Close to update" popup and got this, maybe some unrelated fluke, but still weird:

this keeps happening (seemingly) randomly

@vikiival
Copy link
Member

@vikiival
Copy link
Member

Looks like there is still some cache

I suspect vue-persist.

@yangwao yangwao added p1 preventing everyone from using app $$ ~51-150usd labels Sep 23, 2022
@yangwao
Copy link
Member

yangwao commented Sep 25, 2022

Hey, I guess time to figure out these cache issues with browser cache as some people have old endpoint after we've updated snek RPC for example

@preschian
Copy link
Member

Looks like there is still some cache
I suspect vue-persist.

hhmm, let me check on this one

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.

5 participants