Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection Lost #70

oohnoitz opened this issue Sep 14, 2013 · 4 comments

Connection Lost #70

oohnoitz opened this issue Sep 14, 2013 · 4 comments


Copy link

@oohnoitz oohnoitz commented Sep 14, 2013

I believe that there is an issue with the removal and replacement of idle connections from the pool. It continues to keep adding 4 new connections after the default idleTimeoutMillis setting is reached for the newest connections created and doesn't remove/replace any of the older connections at all. This cycle repeats until the oldest/first connections in the pool reaches the timeout variable set in MySQL and outputs the following error:

Error: Connection lost: The server closed the connection.
    at Protocol.end (/vagrant/www/api/node_modules/mysql/lib/protocol/Protocol.js:73:13)
    at Socket.onend (stream.js:79:10)
    at Socket.EventEmitter.emit (events.js:117:20)
    at _stream_readable.js:920:16
    at process._tickCallback (node.js:415:13)

It might be an issue in generic-pool-redux, but I'm not entirely sure since I am using Knex.js to handle everything. If you leave the following code running and continue to check MySQL's process list, you might be able to see what is happening.

var Knex = require('knex'),
    db = Knex.initialize({
      client: 'mysql',
      connection: {
        host: "",
        user: "root",
        database: "test"
elliotf pushed a commit to elliotf/knex that referenced this issue Nov 24, 2014
Fix for knex#70, omitting options.columns when eager
loading relations.

Internal refactoring of the Collection object to match
the Model, adding the _handleResponse and _handleEager
methods. Test cleanup to match the mocha-as-promised
syntax universally.
Copy link

@cmitz cmitz commented Jun 12, 2015

@oohnoitz exactly describes my issue, but I have not found a solution yet. The solution without knex would be a function handleDisconnect() found across the internet, but how to handle this with knex.....


Copy link

@tgmcguire tgmcguire commented Jun 30, 2016

@cmitz did you find a solution for this? I've been Googling the heck out of this exact problem and can't seem to find a solution.

Copy link

@cmitz cmitz commented Jul 2, 2016

@tgmcguire since we were building a prototype as school project we forced the server to restart every 5 minutes.

Isn't this solved in a newer version of Knex? Either way you might want to look for a real ORM (Bookshelf or something).

Copy link

@elhigu elhigu commented Jul 2, 2016

Which mysql version are you using? Could you provide some test.js file which i could run for 10 minutes to reproduce the problem? I have never encountered this and would be really happy to try to reproduce the problem. I've been using mariadb for mysql testing though... Interesting to see if it has the same problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

4 participants
You can’t perform that action at this time.