{"action":"created","issue":{"url":"https://api.github.com/repos/myndzi/pool2/issues/30","repository_url":"https://api.github.com/repos/myndzi/pool2","labels_url":"https://api.github.com/repos/myndzi/pool2/issues/30/labels{/name}","comments_url":"https://api.github.com/repos/myndzi/pool2/issues/30/comments","events_url":"https://api.github.com/repos/myndzi/pool2/issues/30/events","html_url":"https://github.com/myndzi/pool2/issues/30","id":188624762,"number":30,"title":"Pool2 acquisition failure causes resource to hang around","user":{"login":"raijinsetsu","id":6809014,"avatar_url":"https://avatars.githubusercontent.com/u/6809014?v=3","gravatar_id":"","url":"https://api.github.com/users/raijinsetsu","html_url":"https://github.com/raijinsetsu","followers_url":"https://api.github.com/users/raijinsetsu/followers","following_url":"https://api.github.com/users/raijinsetsu/following{/other_user}","gists_url":"https://api.github.com/users/raijinsetsu/gists{/gist_id}","starred_url":"https://api.github.com/users/raijinsetsu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raijinsetsu/subscriptions","organizations_url":"https://api.github.com/users/raijinsetsu/orgs","repos_url":"https://api.github.com/users/raijinsetsu/repos","events_url":"https://api.github.com/users/raijinsetsu/events{/privacy}","received_events_url":"https://api.github.com/users/raijinsetsu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":17,"created_at":"2016-11-10T21:36:13Z","updated_at":"2016-11-23T05:07:10Z","closed_at":null,"body":"The call to acquire can timeout, according to the acquireTimeout value. When Pool2 times out the action and tries again, there is nothing to stop the prior acquire attempt. This can lead to resource leakage. The only solution I can think of is to remove the acquireTimeout completely and handle the timeout myself.\r\nExample of the issue:\r\n``` typescript\r\nlet pool = new Pool<tls.ClearTextStream>({\r\n    acquire: (cb: (err: any, res?: tls.ClearTextStream) => void) => {\r\n        let stream = tls.connect(opts);\r\n        stream.once('secureConnect', () => {\r\n            cb.removeAllListeners();\r\n            cb(null, stream);\r\n        });\r\n        stream.once('error', (err: Error) => {\r\n            cb(err);\r\n        });\r\n    },\r\n    acquireTimeout: 2 * 1000,\r\n    min: 2,\r\n    max: 10\r\n    ....\r\n});\r\n```\r\nIf the SSL handshake does not complete within 2 seconds (but completes later), this stream is left open.\r\n\r\nIs the only solution here to disable the acquireTimeout and handle the timeout myself within the acquire function?\r\n"},"comment":{"url":"https://api.github.com/repos/myndzi/pool2/issues/comments/262435551","html_url":"https://github.com/myndzi/pool2/issues/30#issuecomment-262435551","issue_url":"https://api.github.com/repos/myndzi/pool2/issues/30","id":262435551,"user":{"login":"myndzi","id":1588419,"avatar_url":"https://avatars.githubusercontent.com/u/1588419?v=3","gravatar_id":"","url":"https://api.github.com/users/myndzi","html_url":"https://github.com/myndzi","followers_url":"https://api.github.com/users/myndzi/followers","following_url":"https://api.github.com/users/myndzi/following{/other_user}","gists_url":"https://api.github.com/users/myndzi/gists{/gist_id}","starred_url":"https://api.github.com/users/myndzi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/myndzi/subscriptions","organizations_url":"https://api.github.com/users/myndzi/orgs","repos_url":"https://api.github.com/users/myndzi/repos","events_url":"https://api.github.com/users/myndzi/events{/privacy}","received_events_url":"https://api.github.com/users/myndzi/received_events","type":"User","site_admin":false},"created_at":"2016-11-23T05:07:10Z","updated_at":"2016-11-23T05:07:10Z","body":"Fantastic, thanks. Somehow I thought it was a little trickier than that... will investigate."}}
{"actor":{"display_login":"myndzi"}}