-
-
Notifications
You must be signed in to change notification settings - Fork 22
fix: clean up engine listener #23
base: main
Are you sure you want to change the base?
Conversation
203c972 to
3bccffa
Compare
src/createEngineStream.ts
Outdated
| }); | ||
| const onNotification = (message: unknown) => stream.push(message); | ||
| engine.on('notification', onNotification); | ||
| stream.on('end', () => engine.off('notification', onNotification)); |
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.
should this be on('close', ... ? Doesn't the 'end' event get fired for every notification?
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.
you're right, changed it. thanks.
3bccffa to
5b4693e
Compare
mcmire
left a comment
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.
Looks good to me! Thanks for doing this.
|
@iantanwx ^ Oh, looks like we have some conflicts. Would you mind bringing in updates from |
|
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.
|
enginemay be a long-lived object. Failing to clean up thenotificationlistener results in a memory leak in the event that many ephemeral streams are created with the sameengine-- for example, extension popups or browser tabs. This fixes the issue.