trailsjs / trailpack-sequelize

:package: Sequelize.js Trailpack http://sequelizejs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: Cannot read property 'close' of undefined

JAertgeerts opened this issue · comments

I keep getting the following error:
UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'close' of undefined

Oddly enough, on my own development machine I can't reproduce this error. Upon deploying to Heroku or Gitlab CI this error prevents me from successfully running the app.

With both MySQL as Postgres

Is your connexion to the database successful ? Can you put the full error log ?

This is the only log I'm getting with logging set to debug:

2017-01-08T15:44:34.890222+00:00 app[cpuBound.1]: debug: trails event: trailpack:repl:initialized
2017-01-08T15:44:34.890426+00:00 app[cpuBound.1]: debug: trails event: trailpack:router:initialized
2017-01-08T15:44:34.890582+00:00 app[cpuBound.1]: debug: trails event: trailpack:passport:initialized
2017-01-08T15:44:34.890710+00:00 app[cpuBound.1]: debug: trails event: trailpack:footprints:initialized
2017-01-08T15:44:34.890867+00:00 app[cpuBound.1]: debug: trails event: trailpack:autoreload:initialized
2017-01-08T15:44:34.891039+00:00 app[cpuBound.1]: debug: trailpack: initializing express
2017-01-08T15:44:34.894585+00:00 app[cpuBound.1]: info: config.paths.www: No www directory is set, www middleware will not be loaded
2017-01-08T15:44:34.894687+00:00 app[cpuBound.1]: info: config.session.secret: No secret given so session are disabled
2017-01-08T15:44:34.927572+00:00 app[cpuBound.1]: debug: trails event: webserver:http:ready
2017-01-08T15:44:34.927724+00:00 app[cpuBound.1]: debug: trails event: trailpack:express:initialized
2017-01-08T15:44:34.976731+00:00 app[cpuBound.1]: error:
2017-01-08T15:44:34.976734+00:00 app[cpuBound.1]:
2017-01-08T15:44:34.976846+00:00 app[cpuBound.1]: error: The application did not boot successfully.
2017-01-08T15:44:34.976954+00:00 app[cpuBound.1]: error: Try increasing the loglevel to "debug" to learn more
2017-01-08T15:44:34.977108+00:00 app[cpuBound.1]: debug: trails event: trails:stop
2017-01-08T15:44:34.977415+00:00 app[cpuBound.1]: info: Shutting down...
2017-01-08T15:44:35.009773+00:00 app[cpuBound.1]: debug: Unloading trailpack repl ...
2017-01-08T15:44:35.010160+00:00 app[cpuBound.1]: debug: Unloading trailpack router ...
2017-01-08T15:44:35.010381+00:00 app[cpuBound.1]: debug: Unloading trailpack passport ...
2017-01-08T15:44:35.010600+00:00 app[cpuBound.1]: debug: Unloading trailpack express ...
2017-01-08T15:44:35.011242+00:00 app[cpuBound.1]: debug: Unloading trailpack sequelize ...
2017-01-08T15:44:35.012815+00:00 app[cpuBound.1]: debug: Unloading trailpack footprints ...
2017-01-08T15:44:35.013041+00:00 app[cpuBound.1]: debug: Unloading trailpack tasker ...
2017-01-08T15:44:35.013255+00:00 app[cpuBound.1]: debug: Unloading trailpack autoreload ...
2017-01-08T15:44:35.014191+00:00 app[cpuBound.1]: debug: All trailpacks unloaded. Done.
2017-01-08T15:44:35.014379+00:00 app[cpuBound.1]: debug: trails event: trailpack:tasker:initialized
2017-01-08T15:44:35.077990+00:00 app[cpuBound.1]: error:
2017-01-08T15:44:35.077993+00:00 app[cpuBound.1]:  Error: pool is draining and cannot accept work
2017-01-08T15:44:35.077994+00:00 app[cpuBound.1]:     at Pool.acquire (/app/node_modules/generic-pool/lib/generic-pool.js:385:11)
2017-01-08T15:44:35.077995+00:00 app[cpuBound.1]:     at /app/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:228:17
2017-01-08T15:44:35.077995+00:00 app[cpuBound.1]:     at Promise._execute (/app/node_modules/bluebird/js/release/debuggability.js:300:9)
2017-01-08T15:44:35.077996+00:00 app[cpuBound.1]:     at Promise._resolveFromExecutor (/app/node_modules/bluebird/js/release/promise.js:481:18)
2017-01-08T15:44:35.077996+00:00 app[cpuBound.1]:     at new Promise (/app/node_modules/bluebird/js/release/promise.js:77:14)
2017-01-08T15:44:35.077997+00:00 app[cpuBound.1]:     at ConnectionManager.<anonymous> (/app/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:227:12)
2017-01-08T15:44:35.077998+00:00 app[cpuBound.1]:     at ConnectionManager.tryCatcher (/app/node_modules/bluebird/js/release/util.js:16:23)
2017-01-08T15:44:35.077999+00:00 app[cpuBound.1]:     at Promise._settlePromiseFromHandler (/app/node_modules/bluebird/js/release/promise.js:510:31)
2017-01-08T15:44:35.077999+00:00 app[cpuBound.1]:     at Promise._settlePromise (/app/node_modules/bluebird/js/release/promise.js:567:18)
2017-01-08T15:44:35.078000+00:00 app[cpuBound.1]:     at Promise._settlePromise0 (/app/node_modules/bluebird/js/release/promise.js:612:10)
2017-01-08T15:44:35.078001+00:00 app[cpuBound.1]:     at Promise._settlePromises (/app/node_modules/bluebird/js/release/promise.js:691:18)
2017-01-08T15:44:35.078001+00:00 app[cpuBound.1]:     at Async._drainQueue (/app/node_modules/bluebird/js/release/async.js:133:16)
2017-01-08T15:44:35.078002+00:00 app[cpuBound.1]:     at Async._drainQueues (/app/node_modules/bluebird/js/release/async.js:143:10)
2017-01-08T15:44:35.078003+00:00 app[cpuBound.1]:     at Immediate.Async.drainQueues (/app/node_modules/bluebird/js/release/async.js:17:14)
2017-01-08T15:44:35.078003+00:00 app[cpuBound.1]:     at runCallback (timers.js:637:20)
2017-01-08T15:44:35.078004+00:00 app[cpuBound.1]:     at tryOnImmediate (timers.js:610:5)
2017-01-08T15:44:35.078102+00:00 app[cpuBound.1]: error: The application did not boot successfully.
2017-01-08T15:44:35.078211+00:00 app[cpuBound.1]: error: Try increasing the loglevel to "debug" to learn more
2017-01-08T15:44:35.078323+00:00 app[cpuBound.1]: debug: trails event: trails:stop
2017-01-08T15:44:35.078513+00:00 app[cpuBound.1]: debug: Unloading trailpack repl ...
2017-01-08T15:44:35.078645+00:00 app[cpuBound.1]: debug: Unloading trailpack router ...
2017-01-08T15:44:35.078757+00:00 app[cpuBound.1]: debug: Unloading trailpack passport ...
2017-01-08T15:44:35.079218+00:00 app[cpuBound.1]: debug: Unloading trailpack express ...
2017-01-08T15:44:35.079372+00:00 app[cpuBound.1]: debug: Unloading trailpack sequelize ...
2017-01-08T15:44:35.079631+00:00 app[cpuBound.1]: debug: Unloading trailpack footprints ...
2017-01-08T15:44:35.079739+00:00 app[cpuBound.1]: debug: Unloading trailpack tasker ...
2017-01-08T15:44:35.079878+00:00 app[cpuBound.1]: debug: Unloading trailpack autoreload ...
2017-01-08T15:44:35.081296+00:00 app[cpuBound.1]: (node:17) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'close' of undefined

Database.js:

const POSTGRES_HOST = process.env.POSTGRES_HOST
const POSTGRES_USER = process.env.POSTGRES_USER
const POSTGRES_DB = process.env.POSTGRES_DB
const POSTGRES_PASSWORD = process.env.POSTGRES_PASSWORD
const POSTGRES_SSL = process.env.POSTGRES_SSL

module.exports = {
  stores: {
    Postgres: {
      dialect: 'postgres',
      dialectOptions: {
        ssl: POSTGRES_SSL
      },
      protocol: 'postgres',
      host: POSTGRES_HOST,
      user: POSTGRES_USER,
      password: POSTGRES_PASSWORD,
      database: POSTGRES_DB
    }
  },

  models: {
    migrate: 'none',
    defaultStore: 'Postgres'
  }
}

Environment vars are correctly set and is connecting when I deploy another express app with sequelize to heroku / gitlab. Not with Trails.

Can close, this was related to my tasker configuration rather than sequelize.

Ok cool ! Glad you make it work :)