-
Notifications
You must be signed in to change notification settings - Fork 76
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
Ensure storage objects are destroyed on application teardown in tests #377
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you Michael! That looks great.
I added a small suggestion to add this.isDestroyed
to the guard for _save
.
addon/mixins/storage.js
Outdated
@@ -86,6 +91,7 @@ export default Mixin.create({ | |||
}, | |||
|
|||
_save() { | |||
if (this.isDestroying) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (this.isDestroying) return; | |
if (this.isDestroying || this.isDestroyed) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks updated the guard.
@@ -43,7 +43,8 @@ | |||
"ember-cli-babel": "^7.26.11", | |||
"ember-cli-string-utils": "^1.1.0", | |||
"ember-cli-version-checker": "^5.1.2", | |||
"ember-copy": "^2.0.1" | |||
"ember-copy": "^2.0.1", | |||
"ember-destroyable-polyfill": "^2.0.3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good thinking! ❤️
@Mikek2252 released as v2.0.7. Thanks again for the fix! |
All of my tests are now failing because of this change. We have an instance-initializer that uses ember-local-storage and tries to update it and now it fails on every test saying something along the lines "..tried to set the property of a destroyed object" meaning the ember-local-storage is now destroyed when my instance-initializer tries to use it. |
@Pixelik oh no! Can you share the initializer? |
I will try to find some time and provide you with the code - for now I've downgraded it's ok 🙏 |
@Pixelik have you found a workaround? I'm also having this issue with 2.0.7. |
Resolves #376
This is to ensure that storage objects are destroyed when the app is torn down in tests, currently objects created by
storageFor
are not destroyed after the test is torn down, i think this is because the class is returned by a computed property so is not destroyed by the parent that callsstorageFor
Storage instances of adapters are destroyed but i have added owner injection to ensure that
associateDestroyableChild
does not error with a missing owner.to ensure backward compatibility i have also added the destroyable polyfill