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

A hook (orm) failed to load! #12

Open
granteagon opened this issue Jul 13, 2015 · 3 comments
Open

A hook (orm) failed to load! #12

granteagon opened this issue Jul 13, 2015 · 3 comments

Comments

@granteagon
Copy link

I'm getting an error trying to connect. I'm using an ssh tunnel to expose port 50000 locally, if that helps.

Sails v0.11.0
DB2 LUW v9.7

info: Starting app...

error: A hook (`orm`) failed to load!
/Users/me/Projects/test/node_modules/sails-db2/index.js:224
                if (connection.conn) connection.conn.close(function (err) {
                              ^
TypeError: Cannot read property 'conn' of undefined
    at closeConnection (/Users/me/Projects/test/node_modules/sails-db2/index.js:224:31)
    at forOwn (/Users/me/Projects/test/node_modules/sails-db2/node_modules/lodash/dist/lodash.js:2106:15)
    at Function.forEach (/Users/me/Projects/test/node_modules/sails-db2/node_modules/lodash/dist/lodash.js:3303:9)
    at Object.module.exports.adapter.teardown (/Users/me/Projects/test/node_modules/sails-db2/index.js:232:20)
    at /usr/local/lib/node_modules/sails/lib/hooks/orm/index.js:244:19
    at /usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:122:13
    at _each (/usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:46:13)
    at Object.async.each (/usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:121:9)
    at Sails.hook.teardown (/usr/local/lib/node_modules/sails/lib/hooks/orm/index.js:241:13)
    at Sails.g (events.js:199:16)
    at Sails.emit (events.js:104:17)
    at Sails.emitter.emit (/usr/local/lib/node_modules/sails/lib/app/private/after.js:50:11)
    at /usr/local/lib/node_modules/sails/lib/app/lower.js:60:11
    at beforeShutdown (/usr/local/lib/node_modules/sails/lib/app/lower.js:35:12)
    at Sails.lower (/usr/local/lib/node_modules/sails/lib/app/lower.js:39:3)
    at Sails.bound (/usr/local/lib/node_modules/sails/node_modules/lodash/dist/lodash.js:729:21)
@federico-razzoli
Copy link
Contributor

Please share your code, so we can try to reproduce the bug.

@jthomas
Copy link

jthomas commented Sep 16, 2015

I've run into this bug recently. Looking at the code, https://github.com/IbuildingsItaly/sails-db2/blob/master/index.js#L223-L232, when the teardown method is called without a name it iterates through all the available connections. The first argument to that closeConnection method becomes the entire connection object not the name. This is causing the bug referenced above.

@gggordon
Copy link
Contributor

I submitted a pull request for this when I had the same issue #15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants