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(core): improve event listener cleanup #4258

Merged
merged 1 commit into from
May 13, 2023
Merged

Conversation

thsig
Copy link
Collaborator

@thsig thsig commented May 13, 2023

What this PR does / why we need it:

Closes #4186.

Before this fix, we weren't removing event listeners registered by the plugin event brokers (mostly for the _exit and _restart control events).

This is now done in a simple way via the new onKey  and clearKey methods on the event bus, which facilitates removing all listeners matching a given key.

We use garden.sessionId as the key now, which is not quite ideal when running concurrent commands in garden dev, but we'll be assigning a command-unique sessionId in an upcoming PR (which gives us precisely the semantics we want here).

Which issue(s) this PR fixes:

Fixes #4186 and #2422.

Closes #4186.

Before this fix, we weren't removing event listeners registered by the
plugin event brokers (mostly for the `_exit` and `_restart` control
events).

This is now done in a simple way via the new `onKey`  and `clearKey`
methods on the event bus, which facilitates removing all listeners
matching a given key.

We use `garden.sessionId` as the key now, which is not quite ideal
when running concurrent commands in `garden dev`, but we'll be assigning
a command-unique `sessionId` in an upcoming PR (which gives us precisely
the semantics we want here).
@thsig thsig requested a review from edvald May 13, 2023 18:23
@thsig thsig merged commit c95e3d5 into 0.13 May 13, 2023
34 checks passed
@thsig thsig deleted the clean-up-event-listeners branch May 13, 2023 19:11
Comment on lines +315 to +316
// "_exit",
// "_restart",
Copy link
Collaborator

Choose a reason for hiding this comment

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

@thsig should these commented lines be removed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, they should—my bad.

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.

None yet

3 participants