myndzi / pool2

38 stars 8 forks source link

Error: Connection lost: The server closed the connection. #18

Closed danielgindi closed 8 years ago

danielgindi commented 8 years ago

I thought that the pool is supposed to handle closed connections?.. But an app crashes periodically because of this.

And of course it is not reasonable to query for all of the open connections in the pool, and periodically send a keep alive...


events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: Connection lost: The server closed the connection.
    at Protocol.end (/home/yehuda/app/node_modules/mysql/lib/protocol/Protocol.js:103:13)
    at Socket.<anonymous> (/home/yehuda/app/node_modules/mysql/lib/Connection.js:102:28)
    at Socket.emit (events.js:117:20)
    at _stream_readable.js:944:16
    at process._tickCallback (node.js:448:13)
    --------------------
    at Protocol._enqueue (/home/yehuda/app/node_modules/mysql/lib/protocol/Protocol.js:135:48)
    at Connection.query (/home/yehuda/app/node_modules/mysql/lib/Connection.js:201:25)
    at /home/yehuda/app/node_modules/knex/lib/dialects/mysql/index.js:80:18
    at tryCatcher (/home/yehuda/app/node_modules/bluebird/js/main/util.js:26:23)
    at Promise._resolveFromResolver (/home/yehuda/app/node_modules/bluebird/js/main/promise.js:480:31)
    at new Promise (/home/yehuda/app/node_modules/bluebird/js/main/promise.js:70:37)
    at Client._stream (/home/yehuda/app/node_modules/knex/lib/dialects/mysql/index.js:77:12)
    at Client.stream (/home/yehuda/app/node_modules/knex/lib/client.js:137:25)
    at /home/yehuda/app/node_modules/knex/lib/runner.js:94:28
    at tryCatcher (/home/yehuda/app/node_modules/bluebird/js/main/util.js:26:23)
    at Promise._settlePromiseFromHandler (/home/yehuda/app/node_modules/bluebird/js/main/promise.js:507:31)
    at Promise._settlePromiseAt (/home/yehuda/app/node_modules/bluebird/js/main/promise.js:581:18)
    at Async._drainQueue (/home/yehuda/app/node_modules/bluebird/js/main/async.js:128:12)
    at Async._drainQueues (/home/yehuda/app/node_modules/bluebird/js/main/async.js:133:10)
    at Async.drainQueues (/home/yehuda/app/node_modules/bluebird/js/main/async.js:15:14)
    at process._tickCallback (node.js:448:13)
danielgindi commented 8 years ago

Well from investigating the code, I've come to the conclusion that this belongs in the knex module, as the pool itself does not have any knowledge of specifics of the mysql module

myndzi commented 8 years ago

You got it. Thanks :)

Could be that the mysql module's api changed recently or something; I know that error handlers are bound in knex, though a similar problem to this happened at one point with postgres.