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

[BUGFIX] Fix willDestroy on class helpers #18837

Merged
merged 1 commit into from
Mar 26, 2020

Conversation

pzuraq
Copy link
Contributor

@pzuraq pzuraq commented Mar 24, 2020

Class based helpers were having willDestroy be called twice, once by
the Glimmer VM's built-in destroyables implementation, and once
scheduled by destroy (which is the correct destruction). This is
because we were registering the class itself directly as the
destroyable, and Glimmer VM detected the willDestroy function on it
and called it eagerly.

This fix creates an intermediate destructor object with a destroy()
hook, but long term we need to finish the refactors to destroyables in
the VM and make it so these types of collisions can't happen again.

Added a basic lifecycle test for helpers to prevent this specific issue
from reoccuring.

Fixes #18830

@rwjblue
Copy link
Member

rwjblue commented Mar 25, 2020

Can you update this to [BUGFIX release]?

Class based helpers were having `willDestroy` be called twice, once by
the Glimmer VM's built-in destroyables implementation, and once
scheduled by `destroy` (which is the correct destruction). This is
because we were registering the class itself directly as the
destroyable, and Glimmer VM detected the `willDestroy` function on it
and called it eagerly.

This fix creates an intermediate destructor object with a `destroy()`
hook, but long term we need to finish the refactors to destroyables in
the VM and make it so these types of collisions can't happen again.

Added a basic lifecycle test for helpers to prevent this specific issue
from reoccuring.
@pzuraq pzuraq force-pushed the bugfix/fix-will-destroy-on-helpers branch from de1d1b5 to ed1f64b Compare March 25, 2020 19:05
@rwjblue rwjblue merged commit 0c39b56 into master Mar 26, 2020
@rwjblue rwjblue deleted the bugfix/fix-will-destroy-on-helpers branch March 26, 2020 12:27
rwjblue pushed a commit that referenced this pull request Mar 26, 2020
Class based helpers were having `willDestroy` be called twice, once by
the Glimmer VM's built-in destroyables implementation, and once
scheduled by `destroy` (which is the correct destruction). This is
because we were registering the class itself directly as the
destroyable, and Glimmer VM detected the `willDestroy` function on it
and called it eagerly.

This fix creates an intermediate destructor object with a `destroy()`
hook, but long term we need to finish the refactors to destroyables in
the VM and make it so these types of collisions can't happen again.

Added a basic lifecycle test for helpers to prevent this specific issue
from reoccuring.

(cherry picked from commit ed1f64b)
rwjblue pushed a commit that referenced this pull request Mar 26, 2020
Class based helpers were having `willDestroy` be called twice, once by
the Glimmer VM's built-in destroyables implementation, and once
scheduled by `destroy` (which is the correct destruction). This is
because we were registering the class itself directly as the
destroyable, and Glimmer VM detected the `willDestroy` function on it
and called it eagerly.

This fix creates an intermediate destructor object with a `destroy()`
hook, but long term we need to finish the refactors to destroyables in
the VM and make it so these types of collisions can't happen again.

Added a basic lifecycle test for helpers to prevent this specific issue
from reoccuring.

(cherry picked from commit ed1f64b)
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.

Class-based helpers' willDestroy() hook called multiple times in tests
2 participants