Sunday, 14 May 2017

Sequelize, MySQL, and Quit inactivity on timeout for Heroku deploy

I am attempting to deploy a nodejs SPA to Heroku using Sequelize and a MySQL database through ClearDB. The app works locally, builds on Heroku successfully, and crashes when I request it from a browser with the following error:

2017-05-15T01:57:11.830234+00:00 app[web.1]: Unhandled rejection SequelizeConnectionError: Quit inactivity timeout
2017-05-15T01:57:11.830243+00:00 app[web.1]:     at Quit._callback (/app/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:136:30)
2017-05-15T01:57:11.830244+00:00 app[web.1]:     at Quit.Sequence.end (/app/node_modules/mysql/lib/protocol/sequences/Sequence.js:86:24)
2017-05-15T01:57:11.830245+00:00 app[web.1]:     at /app/node_modules/mysql/lib/protocol/Protocol.js:399:18
2017-05-15T01:57:11.830246+00:00 app[web.1]:     at Array.forEach (native)
2017-05-15T01:57:11.830246+00:00 app[web.1]:     at /app/node_modules/mysql/lib/protocol/Protocol.js:398:13
2017-05-15T01:57:11.830247+00:00 app[web.1]:     at _combinedTickCallback (internal/process/next_tick.js:73:7)
2017-05-15T01:57:11.830248+00:00 app[web.1]:     at process._tickCallback (internal/process/next_tick.js:104:9)
2017-05-15T01:57:24.016935+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/" host=widg.herokuapp.com request_id=cc5ac3b0-c003-46df-af32-e80f46d56a0b fwd="69.140.81.157" dyno=web.1 connect=1ms service=30000ms status=503 bytes=0 protocol=http
2017-05-15T01:57:24.018979+00:00 app[web.1]: GET / - - ms - -
2017-05-15T01:57:24.324884+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=widg.herokuapp.com request_id=85abc16a-8ef9-4a07-81d4-1a6bf43a6579 fwd="69.140.81.157" dyno=web.1 connect=1ms service=33ms status=500 bytes=318 protocol=http

Based on various threads I read that might have been dealing with the same problem, I tried adding some additional pool setup for Sequelize with the following in my sequelize index.js

if (config.use_env_variable) {
  var sequelize = new Sequelize(process.env[config.use_env_variable], {
    dialect: 'mysql',
    protocol: 'mysql',
    pool: { idle: 120000, max: 5, min: 0},
    logging: true //false
  });
} else {
  var sequelize = new Sequelize(config.database, config.username, config.password, config);
}

The relevant piece of my configuration .json is simply:

  "production": {
    "use_env_variable": "DATABASE_URL"
  }

Note that I did assign the CLEARDB_DATABASE_URL to DATABASE_URL, so that's not the issue. Additionally, I had no problem using my sequelize migration files to setup the database, so it clearly can connect.

Current leading questions I have are:

  • Do need to setup a specific port for Sequelize to communicate with the Database beyond the CLEARDB environment variable?

  • Is there something I need to do with a socket file somewhere?

Many thanks in advance for any help or ideas of things to try.



via mscottnelson

No comments:

Post a Comment