Skip to content
This repository was archived by the owner on Nov 9, 2023. It is now read-only.

Conversation

@iantanwx
Copy link

@iantanwx iantanwx commented Jul 6, 2022

engine may be a long-lived object. Failing to clean up the notification listener results in a memory leak in the event that many ephemeral streams are created with the same engine -- for example, extension popups or browser tabs. This fixes the issue.

@iantanwx iantanwx requested a review from a team as a code owner July 6, 2022 10:30
@iantanwx iantanwx force-pushed the fix/cleanup-dangling-listeners branch 2 times, most recently from 203c972 to 3bccffa Compare July 6, 2022 10:35
});
const onNotification = (message: unknown) => stream.push(message);
engine.on('notification', onNotification);
stream.on('end', () => engine.off('notification', onNotification));
Copy link

Choose a reason for hiding this comment

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

should this be on('close', ... ? Doesn't the 'end' event get fired for every notification?

Copy link
Author

Choose a reason for hiding this comment

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

you're right, changed it. thanks.

@iantanwx iantanwx force-pushed the fix/cleanup-dangling-listeners branch from 3bccffa to 5b4693e Compare July 7, 2022 13:16
@legobeat legobeat requested a review from BelfordZ July 12, 2023 04:15
Copy link

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

Looks good to me! Thanks for doing this.

@mcmire
Copy link

mcmire commented Oct 5, 2023

@iantanwx ^ Oh, looks like we have some conflicts. Would you mind bringing in updates from main and resolving those?

@MajorLift
Copy link
Contributor

This library has now been migrated into the core monorepo. This PR has been locked and this repo will be archived shortly. Going forward, releases of this library will only include changes made in the core repo.

  • Please push this branch to core and open a new PR there.
  • Optionally, add a link pointing to the discussion in this PR to provide context.

@MetaMask MetaMask locked and limited conversation to collaborators Nov 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants