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

DbWrapper deprecation #2838

Merged
merged 10 commits into from
May 17, 2021
Merged

DbWrapper deprecation #2838

merged 10 commits into from
May 17, 2021

Conversation

tropicadri
Copy link
Collaborator

Fixes #2801

Changes in workbox-expiration to use idb and deleting DBWrapper.

Copy link
Contributor

@jeffposnick jeffposnick left a comment

Choose a reason for hiding this comment

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

Thanks! This all looks a lot cleaner, and I'm glad we were able to drop so much old code.

I just had the one small comment inline.

@@ -76,7 +78,9 @@ class CacheTimestampsModel {

// Previous versions of `workbox-expiration` used `this._cacheName`
// as the IDBDatabase name.
deleteDatabase(this._cacheName);
if (this?._cacheName) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm curious as to why it's this? instead of this. When would this not be defined?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Glad you asked, I meant to ask you about that, we call the method to upgradeDB in tests, for example: https://github.com/GoogleChrome/workbox/blob/v6/test/workbox-expiration/sw/test-CacheTimestampsModel.mjs#L16, and that is when this would not be defined. I am not sure if this is still the correct way to do this tests, because the test would be the one creating the IDB because it is opened before each test, maybe we should refactor the tests to open the DB only in the test cases that needs it and only by passing the name?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm, that's interesting.

I don't think most of the tests end up ever triggering the IDB upgrade flow, do they? Can we just leave out onupgradeneeded from when we call openDB() in our tests?

I think would be cleaner than having a situation in which we need to use this? in the non-test code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Turns out my approach also wouldn't work, so I sort of separated the dbupgrade and the deleting of old dbs and that seems to work, let me know what you think. Thank you!

@tropicadri tropicadri changed the title Dbwrapper byebye DbWrapper deprecation May 11, 2021
@@ -76,7 +78,9 @@ class CacheTimestampsModel {

// Previous versions of `workbox-expiration` used `this._cacheName`
// as the IDBDatabase name.
deleteDatabase(this._cacheName);
if (this?._cacheName) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm, that's interesting.

I don't think most of the tests end up ever triggering the IDB upgrade flow, do they? Can we just leave out onupgradeneeded from when we call openDB() in our tests?

I think would be cleaner than having a situation in which we need to use this? in the non-test code.

@jeffposnick
Copy link
Contributor

@tropicadri pointed out that onupgradeneeded always runs when going from the initial empty IDB state to an initial IDB instance (not just when going from an initial IDB instance to a new one), so forget what I mentioned about leaving out onupgradeneeded.

As discussed, moving the call to openDB() to run later in the test suite makes the most sense.

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.

Deprecate DBWrapper
2 participants