{"action":"created","issue":{"url":"https://api.github.com/repos/joyent/node/issues/25467","labels_url":"https://api.github.com/repos/joyent/node/issues/25467/labels{/name}","comments_url":"https://api.github.com/repos/joyent/node/issues/25467/comments","events_url":"https://api.github.com/repos/joyent/node/issues/25467/events","html_url":"https://github.com/joyent/node/pull/25467","id":83489398,"number":25467,"title":"events: fix: shared object references","user":{"login":"Hunchmun","id":6274020,"avatar_url":"https://avatars.githubusercontent.com/u/6274020?v=3","gravatar_id":"","url":"https://api.github.com/users/Hunchmun","html_url":"https://github.com/Hunchmun","followers_url":"https://api.github.com/users/Hunchmun/followers","following_url":"https://api.github.com/users/Hunchmun/following{/other_user}","gists_url":"https://api.github.com/users/Hunchmun/gists{/gist_id}","starred_url":"https://api.github.com/users/Hunchmun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hunchmun/subscriptions","organizations_url":"https://api.github.com/users/Hunchmun/orgs","repos_url":"https://api.github.com/users/Hunchmun/repos","events_url":"https://api.github.com/users/Hunchmun/events{/privacy}","received_events_url":"https://api.github.com/users/Hunchmun/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/joyent/node/labels/pr","name":"pr","color":"006b75"},{"url":"https://api.github.com/repos/joyent/node/labels/v0.12","name":"v0.12","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-06-01T13:17:29Z","updated_at":"2015-06-04T19:30:35Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/joyent/node/pulls/25467","html_url":"https://github.com/joyent/node/pull/25467","diff_url":"https://github.com/joyent/node/pull/25467.diff","patch_url":"https://github.com/joyent/node/pull/25467.patch"},"body":"Fixes the issue: https://github.com/joyent/node/issues/25466\r\n\r\nWhen emitting to multiple listeners for the same event type, the for\r\nloop iteration over these listeners shares the same arguments. This\r\nmeans (for objects), the copy is only shallow, and changes made by one\r\nlistener are overwritten on the object for the next listener.\r\n\r\nFor example, if we pass an object with arrays: as below\r\n```js\r\nEventEmitter.emit(\"event\", {\r\n  data: [{\r\n      users: [9237895]\r\n  }]\r\n});\r\n```\r\nAnd the first listener sets the users array as null like so:\r\n```js\r\nEventEmitter.on('event', function(packet) {\r\n    var data = packet.data[0];\r\n    data.users = null;\r\n});\r\n```\r\nThe second event listener will ALWAYS show the array as null. This is\r\nbecause only a shallow copy of the arguments is made and not a deep\r\ncopy.\r\n\r\nThis fixes that issue, by enforcing a deep copy and removing all\r\nreferences from the new arguments array passed to each listener.\r\n\r\nLink to code used to reproduce this issue:\r\nhttps://ghostbin.com/paste/v4ova\r\n\r\nLink to issue:\r\nhttps://github.com/joyent/node/issues/25466"},"comment":{"url":"https://api.github.com/repos/joyent/node/issues/comments/109020164","html_url":"https://github.com/joyent/node/pull/25467#issuecomment-109020164","issue_url":"https://api.github.com/repos/joyent/node/issues/25467","id":109020164,"user":{"login":"jasnell","id":439929,"avatar_url":"https://avatars.githubusercontent.com/u/439929?v=3","gravatar_id":"","url":"https://api.github.com/users/jasnell","html_url":"https://github.com/jasnell","followers_url":"https://api.github.com/users/jasnell/followers","following_url":"https://api.github.com/users/jasnell/following{/other_user}","gists_url":"https://api.github.com/users/jasnell/gists{/gist_id}","starred_url":"https://api.github.com/users/jasnell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasnell/subscriptions","organizations_url":"https://api.github.com/users/jasnell/orgs","repos_url":"https://api.github.com/users/jasnell/repos","events_url":"https://api.github.com/users/jasnell/events{/privacy}","received_events_url":"https://api.github.com/users/jasnell/received_events","type":"User","site_admin":false},"created_at":"2015-06-04T19:30:35Z","updated_at":"2015-06-04T19:30:35Z","body":"Thanks @Hunchmun! ... LGTM"}}