nft-gallery icon indicating copy to clipboard operation
nft-gallery copied to clipboard

Cache (weird) bug on Firefox

Open roiLeo opened this issue 3 years ago • 14 comments
trafficstars

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 avatar Aug 26 '22 12:08 roiLeo

nvm worked after clearing indexDb & cookies

roiLeo avatar Aug 26 '22 12:08 roiLeo

had same in chrome back in July even after updates!

👀

  • #2237

yangwao avatar Aug 26 '22 14:08 yangwao

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

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

roiLeo avatar Aug 29 '22 13:08 roiLeo

Maybe this did not worked as anticipated?

  • https://github.com/kodadot/nft-gallery/pull/3834

yangwao avatar Aug 29 '22 13:08 yangwao

Maybe this did not worked as anticipated?

I think so 🤔

I found this one https://github.com/GoogleChrome/workbox/issues/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

preschian avatar Aug 29 '22 13:08 preschian

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

petersopko avatar Aug 30 '22 10:08 petersopko

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

preschian avatar Aug 30 '22 10:08 preschian

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

yangwao avatar Aug 30 '22 11:08 yangwao

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 #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

preschian avatar Aug 31 '22 02:08 preschian

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

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

roiLeo avatar Aug 31 '22 13:08 roiLeo

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

preschian avatar Sep 01 '22 10:09 preschian

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

this keeps happening (seemingly) randomly

petersopko avatar Sep 12 '22 08:09 petersopko

vikiival avatar Sep 23 '22 10:09 vikiival

Looks like there is still some cache

I suspect vue-persist.

vikiival avatar Sep 23 '22 10:09 vikiival

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

yangwao avatar Sep 25 '22 15:09 yangwao

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

hhmm, let me check on this one

preschian avatar Sep 26 '22 01:09 preschian