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

fix(indexed-db): reset now clears db tables #2445

Merged
merged 8 commits into from
Jul 4, 2023

Conversation

fczuardi
Copy link
Contributor

@fczuardi fczuardi commented May 23, 2023

Co-authored-by: @taboca
Co-authored-by: @mquasar

Describe the changes you have made in this PR

A clear and concise description of what you want to happen

Link this PR to an issue [optional]

Fix: #2435

Type of change

(Remove other not matching type)

  • fix: Bug fix (non-breaking change which fixes an issue)
  • feat: New feature (non-breaking change which adds functionality)
  • feat!: Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • docs: Documentation update

Screenshots of the changes [optional]

Add screenshots to make your changes easier to understand. You can also add a video here.

How has this been tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

Checklist

  • My code follows the style guidelines of this project and performed a self-review of my own code
  • New and existing tests pass locally with my changes
  • I checked if I need to make corresponding changes to the documentation (and made those changes if needed)

@github-actions
Copy link

github-actions bot commented May 23, 2023

🚀 Thanks for the pull request!

Here are the current build files for testing:

Download and unzip the file for your browser. Refer to the readme for detailed install instructions.

Don't forget: keep earning sats!

Copy link
Contributor

@reneaaron reneaaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

As @rolznz noted I think the browser.storage.clear() APIs would be a better fit here as they delete all data and do not need to be adjusted in case there are new tables added in future.

@mquasar
Copy link
Contributor

mquasar commented May 23, 2023

Thanks for the PR!

As @rolznz noted I think the browser.storage.clear() APIs would be a better fit here as they delete all data and do not need to be adjusted in case there are new tables added in future.

We tried that but the data still 'lives on' in the IndexedDB, apparently. Does it make sense?

@taboca
Copy link
Contributor

taboca commented May 24, 2023

Thanks for the PR!

As @rolznz noted I think the browser.storage.clear() APIs would be a better fit here as they delete all data and do not need to be adjusted in case there are new tables added in future.

Thanks for supporting us @reneaaron and @rolznz

Although there is a situation that loading data ( such as payments ) comes from browser.storage API - which would indeed suggest that just deleting browser.storage is enough - yet based on local and limited tests, we have stumbled in a situation where IndexedDB data was persistent.

The part of the code that gives us that idea is the function loadFromStorage:

In addition, notice the following section example where the logic gives up the load sync from browser.storage API in the situation where IndexedDB data exists: https://github.com/getAlby/lightning-browser-extension/blob/5bddad27cd0f58dcb83ffbceb5f3cf1317bb517c/src/extension/background-script/db.ts#LL116C6-L129C12

With the above said it is correct that there is a situation where IndexedDB is not present, which indeed require us to also clear the data from browser.storage

} else if (result.allowances && result.allowances.length > 0) {

Some other observations #2435 (comment)

With the above said, if the suggestion has to do with easy maintenance, and if we do the "browser.storage.clear()" then we would have to keep some consistency with wiping the IndexedDB database entirely too? Another idea is to try to do the maintenance from the loadFromStorage function in db.ts which is the code that gets kicked in app initialization time.

@rolznz
Copy link
Contributor

rolznz commented May 25, 2023

Thanks for the PR!
As @rolznz noted I think the browser.storage.clear() APIs would be a better fit here as they delete all data and do not need to be adjusted in case there are new tables added in future.

Thanks for supporting us @reneaaron and @rolznz

Although there is a situation that loading data ( such as payments ) comes from browser.storage API - which would indeed suggest that just deleting browser.storage is enough - yet based on local and limited tests, we have stumbled in a situation where IndexedDB data was persistent.

The part of the code that gives us that idea is the function loadFromStorage:

In addition, notice the following section example where the logic gives up the load sync from browser.storage API in the situation where IndexedDB data exists: https://github.com/getAlby/lightning-browser-extension/blob/5bddad27cd0f58dcb83ffbceb5f3cf1317bb517c/src/extension/background-script/db.ts#LL116C6-L129C12

With the above said it is correct that there is a situation where IndexedDB is not present, which indeed require us to also clear the data from browser.storage

} else if (result.allowances && result.allowances.length > 0) {

Some other observations #2435 (comment)

With the above said, if the suggestion has to do with easy maintenance, and if we do the "browser.storage.clear()" then we would have to keep some consistency with wiping the IndexedDB database entirely too? Another idea is to try to do the maintenance from the loadFromStorage function in db.ts which is the code that gets kicked in app initialization time.

@mquasar @taboca thanks for testing and looking deeper into the issue. I think the goal is to delete absolutely everything when resetting the extension. So any and all storage mechanisms (indexedDb, browser.storage, etc) we save data to should be completely cleared.

@taboca
Copy link
Contributor

taboca commented May 26, 2023

Thanks for the PR!
As @rolznz noted I think the browser.storage.clear() APIs would be a better fit here as they delete all data and do not need to be adjusted in case there are new tables added in future.

Thanks for supporting us @reneaaron and @rolznz
Although there is a situation that loading data ( such as payments ) comes from browser.storage API - which would indeed suggest that just deleting browser.storage is enough - yet based on local and limited tests, we have stumbled in a situation where IndexedDB data was persistent.
The part of the code that gives us that idea is the function loadFromStorage:

In addition, notice the following section example where the logic gives up the load sync from browser.storage API in the situation where IndexedDB data exists: https://github.com/getAlby/lightning-browser-extension/blob/5bddad27cd0f58dcb83ffbceb5f3cf1317bb517c/src/extension/background-script/db.ts#LL116C6-L129C12
With the above said it is correct that there is a situation where IndexedDB is not present, which indeed require us to also clear the data from browser.storage

} else if (result.allowances && result.allowances.length > 0) {

Some other observations #2435 (comment)
With the above said, if the suggestion has to do with easy maintenance, and if we do the "browser.storage.clear()" then we would have to keep some consistency with wiping the IndexedDB database entirely too? Another idea is to try to do the maintenance from the loadFromStorage function in db.ts which is the code that gets kicked in app initialization time.

@mquasar @taboca thanks for testing and looking deeper into the issue. I think the goal is to delete absolutely everything when resetting the extension. So any and all storage mechanisms (indexedDb, browser.storage, etc) we save data to should be completely cleared.

Ok, I will check then the other aspects of DB that seem to be there, such as "LBE-AVAILABILITY-CHECK" and the ways to clear all the DBs.

@fczuardi
Copy link
Contributor Author

Thanks for the PR!

As @rolznz noted I think the browser.storage.clear() APIs would be a better fit here as they delete all data and do not need to be adjusted in case there are new tables added in future.

We have just updated the patch with the suggestions. It's much simpler now :) Thanks @rolznz !!

@fczuardi fczuardi requested a review from reneaaron June 14, 2023 15:42
@fczuardi fczuardi mentioned this pull request Jun 14, 2023
3 tasks
@rolznz
Copy link
Contributor

rolznz commented Jun 23, 2023

@fczuardi I made some more simplifications. Could you please review the changes?

@fczuardi
Copy link
Contributor Author

@fczuardi I made some more simplifications. Could you please review the changes?

@rolznz from your 3 commits, the first 2 LGTM, the third is probably fine as well, I just left a comment asking if your version is equivalent because I couldn't see 2 attributes nullified.

@rolznz
Copy link
Contributor

rolznz commented Jun 27, 2023

@reneaaron I think this PR is ready for review now. 💪

@bumi
Copy link
Collaborator

bumi commented Jul 3, 2023

looks good to me. @reneaaron have a look and merge.

Copy link
Contributor

@reneaaron reneaaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @fczuardi! 💪

tACK

@reneaaron reneaaron merged commit 898da98 into getAlby:master Jul 4, 2023
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

Successfully merging this pull request may close these issues.

Delete all data when resetting the extension
7 participants