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

Adapter instances should be destroyed #7018

Closed
rwjblue opened this issue Jan 30, 2020 · 1 comment · Fixed by #7020
Closed

Adapter instances should be destroyed #7018

rwjblue opened this issue Jan 30, 2020 · 1 comment · Fixed by #7020
Labels
🏷️ bug This PR primarily fixes a reported issue

Comments

@rwjblue
Copy link
Member

rwjblue commented Jan 30, 2020

It appears that adapter instances are never being destroyed.

Related codepaths:

We configure the adapter type to be non-singleton here:

application.registerOptionsForType('adapter', { singleton: false });

And then we instantiate the adapter instances with owner.lookup here:

adapter = owner.lookup(`adapter:${normalizedModelName}`);

But in the store's willDestroy we do nothing with this._adapterCache (we should loop over them and be calling .destroy())


This is generally not an issue for most users, as they are not commonly doing their own async from within the adapter instances. However, as soon as you attempt to do things like tracking response info (by queueing and firing a request) or doing exponential backoff you might find yourself in a situation where you need to clean up a timer (clearTimeout, runDestroyables, etc). Since we never run adapterInstance.destroy(), the user can't implement willDestroy and have that cleanup code be ran (ember-concurrency and ember-lifeline both leverage .destroy() being called in order to properly cleanup).

@rwjblue
Copy link
Member Author

rwjblue commented Jan 31, 2020

FWIW, this was introduced in #5305 (and has been an issue throughout the entire 3.x series).

@runspired runspired added 🏷️ bug This PR primarily fixes a reported issue and removed Bug labels Sep 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bug This PR primarily fixes a reported issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants