node-express-sequelize-es2015
node-express-sequelize-es2015 copied to clipboard
Some bluebird warinings with un-returned promise
I ve got some bluebird warnings like "Warning: a promise was created in a handler at ... but none were returned from it" - for ex, code in auth.js:
const strategy = new Strategy(params, (payload, done) => {
Users.findById(payload.id)
.then(user => {
if (user) {
return done(null, { // << -- here is problem
id: user.id,
email: user.email,
});
}
return done(null, false);
})
.catch(error => done(error, null));
});
Here is explanation of problem in issue thread: https://github.com/petkaantonov/bluebird/issues/508
Possible fix:
const strategy = new Strategy(params, (payload, done) => {
Users.findById(payload.id)
.then(user => {
if (user) {
return { // << -- fix
id: user.id,
email: user.email,
});
}
return false;
})
.asCallback(done)
.catch(error => done(error, null));
});