Skip to content

Can't promisifyAll Riak-JS library #680

Description

@ryanmeador

I'm trying to promisifyAll the riak client object exposed by the riak-js library, version 1.0.3. I just upgraded Bluebird from 2.9.25 to 2.9.30. There was no problem with the older version. Now I get this error message. I cannot find any method that violates the signature in the riak docs, nor by hand-inspecting the object in question. I added a log statement into Bluebird at promisify.js:46 to print out the value that was failing the check, and it says "apply_" (btw, I think it would be great if the error message included this information). I am unaware of any such function on the riak object so I have no idea what is going on... can you offer any help debugging, or is this perhaps a bug in Bluebird? Thanks.

Edit: I should have mentioned I have created my own promisifier, because all Riak functions' callbacks take 3 arguments (err, result, meta), and I want to discard the meta parameter because it seems to cause issues with Promise (I guess it passes an array or something to the next function in the chain? I didn't try to debug that; I had the same issue with Async before switching to promises and I solved it just by discarding the meta param). Here's my promisifier, where riak is a riak client object and wrapRiakCb is the function that drops the meta param:

module.exports.client = Promise.promisifyAll(riak, { promisifier: function(originalFunction) {
  return function() {
    var args = [].slice.call(arguments);
    var self = this;
    return Promise.fromNode(function(callback) {
      args.push(exports.wrapRiakCb(callback));
      originalFunction.apply(self, args);
    });
  };
}});

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions