{"action":"closed","issue":{"url":"https://api.github.com/repos/Azure/azure-service-bus-node/issues/81","repository_url":"https://api.github.com/repos/Azure/azure-service-bus-node","labels_url":"https://api.github.com/repos/Azure/azure-service-bus-node/issues/81/labels{/name}","comments_url":"https://api.github.com/repos/Azure/azure-service-bus-node/issues/81/comments","events_url":"https://api.github.com/repos/Azure/azure-service-bus-node/issues/81/events","html_url":"https://github.com/Azure/azure-service-bus-node/issues/81","id":391834628,"node_id":"MDU6SXNzdWUzOTE4MzQ2Mjg=","number":81,"title":"EventEmitter leak in the batchingReceiver","user":{"login":"gcstarr","id":31420876,"node_id":"MDQ6VXNlcjMxNDIwODc2","avatar_url":"https://avatars3.githubusercontent.com/u/31420876?v=4","gravatar_id":"","url":"https://api.github.com/users/gcstarr","html_url":"https://github.com/gcstarr","followers_url":"https://api.github.com/users/gcstarr/followers","following_url":"https://api.github.com/users/gcstarr/following{/other_user}","gists_url":"https://api.github.com/users/gcstarr/gists{/gist_id}","starred_url":"https://api.github.com/users/gcstarr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gcstarr/subscriptions","organizations_url":"https://api.github.com/users/gcstarr/orgs","repos_url":"https://api.github.com/users/gcstarr/repos","events_url":"https://api.github.com/users/gcstarr/events{/privacy}","received_events_url":"https://api.github.com/users/gcstarr/received_events","type":"User","site_admin":false},"labels":[{"id":464395067,"node_id":"MDU6TGFiZWw0NjQzOTUwNjc=","url":"https://api.github.com/repos/Azure/azure-service-bus-node/labels/bug","name":"bug","color":"ee0701","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-12-17T18:22:39Z","updated_at":"2018-12-18T04:07:22Z","closed_at":"2018-12-18T04:07:21Z","author_association":"NONE","body":"**Describe the bug**\r\nThere is an eventEmitter leak in the batchingReceiver.\r\n\r\n**To Reproduce**\r\n* With the same client instance, call receiveBatch more than 10 times.\r\n* The MaxListenersExceededWarning is received as the sessionError listener is added at every call, but never removed.\r\n\r\n**Expected behavior**\r\nEvent emitters are correctly managed.\r\n\r\n**Proposed fix:**\r\n```\r\n--- a/lib/core/batchingReceiver.ts\r\n+++ b/lib/core/batchingReceiver.ts\r\n@@ -96,6 +96,7 @@ export class BatchingReceiver extends MessageReceiver {\r\n         if (this._receiver) {\r\n           this._receiver.removeListener(ReceiverEvents.receiverError, onReceiveError);\r\n           this._receiver.removeListener(ReceiverEvents.message, onReceiveMessage);\r\n+          this._receiver.session.removeListener(SessionEvents.sessionError, onReceiveError);\r\n         }\r\n```\r\n"}}
{"actor":{"display_login":"ramya-rao-a"}}