{"action":"opened","issue":{"url":"https://api.github.com/repos/primus/primus/issues/363","labels_url":"https://api.github.com/repos/primus/primus/issues/363/labels{/name}","comments_url":"https://api.github.com/repos/primus/primus/issues/363/comments","events_url":"https://api.github.com/repos/primus/primus/issues/363/events","html_url":"https://github.com/primus/primus/issues/363","id":65945636,"number":363,"title":"Cannot read `timeout` of undefined caused by WebSocket heartbeat","user":{"login":"STRML","id":1197375,"avatar_url":"https://avatars.githubusercontent.com/u/1197375?v=3","gravatar_id":"","url":"https://api.github.com/users/STRML","html_url":"https://github.com/STRML","followers_url":"https://api.github.com/users/STRML/followers","following_url":"https://api.github.com/users/STRML/following{/other_user}","gists_url":"https://api.github.com/users/STRML/gists{/gist_id}","starred_url":"https://api.github.com/users/STRML/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/STRML/subscriptions","organizations_url":"https://api.github.com/users/STRML/orgs","repos_url":"https://api.github.com/users/STRML/repos","events_url":"https://api.github.com/users/STRML/events{/privacy}","received_events_url":"https://api.github.com/users/STRML/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-04-02T15:02:05Z","updated_at":"2015-04-02T15:02:05Z","closed_at":null,"body":"This is one it looks like I caused via #323, but I wanted to ask a question about it.\r\n\r\nThe error:\r\n\r\n```\r\nTypeError: Cannot read property 'timeout' of undefined\r\n    at Sparky.heartbeat (/srv/www/api/shared/node_modules/primus/spark.js:109:39)\r\n    at WebSocket.emit (events.js:98:17)\r\n    at Receiver.onping (/srv/www/api/shared/node_modules/ws/lib/WebSocket.js:816:10)\r\n    at /srv/www/api/shared/node_modules/ws/lib/Receiver.js:645:14\r\n    at Receiver.flush (/srv/www/api/shared/node_modules/ws/lib/Receiver.js:336:3)\r\n    at Receiver.opcodes.9.finish (/srv/www/api/shared/node_modules/ws/lib/Receiver.js:648:12)\r\n    at Receiver.expectHandler (/srv/www/api/shared/node_modules/ws/lib/Receiver.js:630:33)\r\n    at Receiver.add (/srv/www/api/shared/node_modules/ws/lib/Receiver.js:91:24)\r\n    at Socket.firstHandler (/srv/www/api/shared/node_modules/ws/lib/WebSocket.js:775:22)\r\n    at Socket.emit (events.js:95:17)\r\n    at Socket.<anonymous> (_stream_readable.js:748:14)\r\n    at Socket.emit (events.js:92:17)\r\n    at emitReadable_ (_stream_readable.js:410:10)\r\n    at emitReadable (_stream_readable.js:406:5)\r\n    at readableAddChunk (_stream_readable.js:168:9)\r\n    at Socket.Readable.push (_stream_readable.js:130:10)\r\n```\r\n\r\nIt appears that the `primus` property has been removed from the socket, but the underlying transformer is still receiving a `ping` event and calling `spark.heartbeat()`.\r\n\r\nI can't see where the `primus` property is removed from `spark`, but I would assume it's on destruction; but in that case, why wouldn't `'close'` have been fired, which [removes all listeners](https://github.com/primus/primus/blob/master/transformers/websockets/server.js#L60)?"}}