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

Can't promisifyAll Riak-JS library #680

Closed
ryanmeador opened this Issue Jun 29, 2015 · 3 comments

Comments

Projects
None yet
3 participants
@ryanmeador

ryanmeador commented Jun 29, 2015

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);
    });
  };
}});
@petkaantonov

This comment has been minimized.

Show comment
Hide comment
@petkaantonov

petkaantonov Jul 1, 2015

Owner

Doesn't reproduce with

var Promise = require("bluebird");
var riak = require("riak-js")({});
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);
    });
  };
}});
Owner

petkaantonov commented Jul 1, 2015

Doesn't reproduce with

var Promise = require("bluebird");
var riak = require("riak-js")({});
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);
    });
  };
}});
@benjamingr

This comment has been minimized.

Show comment
Hide comment
@benjamingr

benjamingr Jul 3, 2015

Collaborator

@ryanmeador anything?

Collaborator

benjamingr commented Jul 3, 2015

@ryanmeador anything?

@ryanmeador

This comment has been minimized.

Show comment
Hide comment
@ryanmeador

ryanmeador Jul 6, 2015

I apologize for not getting back to you sooner, I was on vacation. I still see the problem, so I spent some time coming up with a minimal reproducer. My mind is blown. The problem only manifests if I require() a 1.x version of neo4j in addition to riak! How is that even possible?

Because I can't seem to attach a ZIP to this issue, I created a repo for my reproducer: https://github.com/ryanmeador/bluebird680reproducer

Please note that, as specified in the package.json, the version of neo4j that causes the error must be 1.x (or at least not latest). I have no idea what is going on. Thanks for your attention so far.

ryanmeador commented Jul 6, 2015

I apologize for not getting back to you sooner, I was on vacation. I still see the problem, so I spent some time coming up with a minimal reproducer. My mind is blown. The problem only manifests if I require() a 1.x version of neo4j in addition to riak! How is that even possible?

Because I can't seem to attach a ZIP to this issue, I created a repo for my reproducer: https://github.com/ryanmeador/bluebird680reproducer

Please note that, as specified in the package.json, the version of neo4j that causes the error must be 1.x (or at least not latest). I have no idea what is going on. Thanks for your attention so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment