{"action":"created","issue":{"url":"https://api.github.com/repos/sidorares/node-mysql2/issues/162","labels_url":"https://api.github.com/repos/sidorares/node-mysql2/issues/162/labels{/name}","comments_url":"https://api.github.com/repos/sidorares/node-mysql2/issues/162/comments","events_url":"https://api.github.com/repos/sidorares/node-mysql2/issues/162/events","html_url":"https://github.com/sidorares/node-mysql2/issues/162","id":60168657,"number":162,"title":"Heroku / ClearDB connections not closing","user":{"login":"chrisveness","id":1066395,"avatar_url":"https://avatars.githubusercontent.com/u/1066395?v=3","gravatar_id":"","url":"https://api.github.com/users/chrisveness","html_url":"https://github.com/chrisveness","followers_url":"https://api.github.com/users/chrisveness/followers","following_url":"https://api.github.com/users/chrisveness/following{/other_user}","gists_url":"https://api.github.com/users/chrisveness/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisveness/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisveness/subscriptions","organizations_url":"https://api.github.com/users/chrisveness/orgs","repos_url":"https://api.github.com/users/chrisveness/repos","events_url":"https://api.github.com/users/chrisveness/events{/privacy}","received_events_url":"https://api.github.com/users/chrisveness/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/sidorares/node-mysql2/labels/needs%20investigation","name":"needs investigation","color":"207de5"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-03-06T22:32:55Z","updated_at":"2015-03-10T12:23:58Z","closed_at":null,"body":"Using Heroku + ClearDB (1-dyno / ignite), it seems that `connection.end()` doesn't close the connection - `SHOW PROCESSLIST` shows connections building up with each page request in the same way as they do if I don't call `connection.end()` when using MySQL on localhost – after 10 pages refreshes, the app crashes.\r\n\r\nHave you any idea what might cause this, or how to solve it?\r\n\r\nCode to replicate it is as follows:\r\n\r\n````sql\r\nvar koa   = require('koa');\r\nvar mysql = require('mysql-co');\r\n\r\nvar app = koa();\r\n\r\napp.use(function* mysqlConnection(next) {\r\n\r\n    var opt = { host: 'localhost', database: 'test', user: 'test', password: 'test' };\r\n    var opt = { host: 'xxx.cleardb.com', database: 'heroku_xxx', user: 'xxx', password: 'xxx' };\r\n    this.db = mysql.createConnection(opt);\r\n    this.db.connect();\r\n\r\n    yield next;\r\n\r\n    this.db.end();\r\n});\r\n\r\napp.use(function* query(next) {\r\n    var result = yield this.db.query('show processlist');\r\n    console.log(result[0]);\r\n});\r\n\r\napp.listen(3000);\r\n````\r\n\r\nUsing the cleardb opt processes build up in the same way as the localhost opt does with the call to ` this.db.end()` removed.\r\n\r\nBehaviour is same on Node.js v0.12.0 and io.js v1.4.3."},"comment":{"url":"https://api.github.com/repos/sidorares/node-mysql2/issues/comments/78043045","html_url":"https://github.com/sidorares/node-mysql2/issues/162#issuecomment-78043045","issue_url":"https://api.github.com/repos/sidorares/node-mysql2/issues/162","id":78043045,"user":{"login":"sidorares","id":173025,"avatar_url":"https://avatars.githubusercontent.com/u/173025?v=3","gravatar_id":"","url":"https://api.github.com/users/sidorares","html_url":"https://github.com/sidorares","followers_url":"https://api.github.com/users/sidorares/followers","following_url":"https://api.github.com/users/sidorares/following{/other_user}","gists_url":"https://api.github.com/users/sidorares/gists{/gist_id}","starred_url":"https://api.github.com/users/sidorares/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sidorares/subscriptions","organizations_url":"https://api.github.com/users/sidorares/orgs","repos_url":"https://api.github.com/users/sidorares/repos","events_url":"https://api.github.com/users/sidorares/events{/privacy}","received_events_url":"https://api.github.com/users/sidorares/received_events","type":"User","site_admin":false},"created_at":"2015-03-10T12:23:58Z","updated_at":"2015-03-10T12:23:58Z","body":"@chrisveness could you try master? ( or wait couple of days, I'd like to finish something else before publishing v0.15.4 )"}}