Thavaprakash Swaminathan
Thavaprakash Swaminathan

Reputation: 6976

Warning: a promise was created in a handler - bluebird

I'm getting below warning error, please guide me to fix it.

Warning: a promise was created in a handler at anonymous> (/opt/testproj/node_modules/pipeworks/pipeworks.js:72:17but was not returned from it, see http://bluebirdjs.com/docs/warning-explanations.html#warning-a-promise-was-created-in-a-handler-but-was-not-returned-from-it at new Promise (/opt/testproj/node_modules/bluebird/js/release/promise.js:77:14)

Sample code:

const bluebird = require('bluebird');
const options = {
                  promiseLib: bluebird
                };
const pgpromise = require('pg-promise')(options);
const connectionString = `postgres://${user}:${password}@${host}:${port}/${database}`; 
const db = pgpromise(connectionString);


db.func('student__find_by_id', [id])                                       
.then((data) => {                                                                                                                   
  return res.json(data);
}).catch((err) => {
   log.error(err);                                                                                                              
});

Upvotes: 0

Views: 1130

Answers (1)

vitaly-t
vitaly-t

Reputation: 25840

As per my earlier comments, the code shown here cannot throw the error you describe. And situations like this one are comprehensively covered within pg-promise tests.

You should use Bluebird's Long Stack Tracing feature to correctly identify the code that results in this error:

var Promise = require('bluebird');

Promise.config({
    longStackTraces: true
});

Upvotes: 2

Related Questions