Skip to content

Fix repeated event listener cleanup - #289

Open
bensynapse wants to merge 1 commit into
IjzerenHein:mainfrom
bensynapse:fix-listener-cleanup
Open

bensynapse wants to merge 1 commit into
IjzerenHein:mainfrom
bensynapse:fix-listener-cleanup

Conversation

@bensynapse

Copy link
Copy Markdown

I run Live Tennis API.

Calling an EventEmitter cleanup twice currently removes another listener. The second call passes -1 to splice after the original callback is gone.

Each cleanup now removes its registration once. Repeated calls leave other listeners and later registrations of the same callback alone.

Eight Jest cases cover repeated cleanup, duplicate callbacks, listener order and separate event names. Six fail against unchanged main.

Checked on Node 22.23.2 with yarn test --runInBand --watch=false --coverage, yarn build and yarn lint. All pass. EventEmitter statement coverage is 100%.

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.

1 participant