For promisifyAll() to work, the function must be asynchronous, and the last argument passed to the function must be a completion callback, and the completion callback must have an error argument as the first argument, which is false when there is no error and return value as the second argument (if there is a value).
Your function does not meet any of these criteria.
Here is an excerpt from a Bluebird document for .promisifyAll() :
It is assumed that the target methods correspond to the node.js callback agreement on accepting the callback as the last argument and the error callback as the first argument and the success value on the second argument. If the node method calls its callback with multiple success values, the execution value will be their array.
Remember that .promisifyAll() cannot perform a synchronous operation in an async operation. What happens is to perform an asynchronous operation that matches a specific calling convention, and wraps it in a promise by attaching a callback and checking the callback arguments to detect success or failure and propagate the return value.
If you are interested in how Bluebird does this, you can check their actual code here on Github , although it is not very easy to keep track of what it is doing without any significant study.
Here's a slightly simpler version of the promisify function to just see what it does (I would recommend using Bluebird for all other functions, not for that).
// -------------------------------------------------------------- // promisify(fn, obj) // // Pass an async function that takes as its last argument a callback // that conforms to the node.js callback calling convention function(err, result) // passing obj is optional. If present the function passed in will be called // as obj.method() // // Returns: New function that when called will return a promise. // -------------------------------------------------------------- function promisify(fn, obj) { if (typeof fn !== "function") { throw new Error("fn argument to promisify() must be function"); } // obj is optional and may be undefined // if present, it will be used as context to call fn as in obj.fn() return function(/* args */) { // make copy of arguments object into a real array in a way that // does not prevent interpreter optimizations var args = new Array(arguments.length); for (var i = 0; i < args.length; i++) { args[i] = arguments[i]; } return new Promise(function(resolve, reject) { // add our callback function at the end of the args list var resultMany; args.push(function(err, result) { if (err) { reject(err); } else { // if 0 or 1 result, then just return it as a simple value if (arguments.length <= 2) { resolve(result); } else { // if more than one result came with the callback function, // then put it into an array so we can resolve with a single value (the array of results) // skip the first argument which is the err value resultMany = new Array(arguments.length - 1); for (var i = 0; i < arguments.length - 1; i++) { resultMany[i] = arguments[i + 1]; } resolve(resultMany); } } }); // call original function with our callback as last argument fn.apply(obj, args); }); } }
Here's a working demo of this promisify() function: https://jsfiddle.net/jfriend00/m1265vos/