Search code examples
c++node.jsv8

Nodejs C++ event emitter. add-on error. Non-function in MakeCallback. method = emit Abort trap: 6


I'm creating a C++ level event emitter addon for node.js. I'm getting this C++ error when including the add-on in a node.js project.

Non-function in MakeCallback. method = emit Abort trap: 6

I found this Gist with a simplified example of the same behavior: https://gist.github.com/jedi4ever/4250746

Hoping for some general insight into why this might be caused or what this error means.


Solution

  • If I understand what you're trying to do correctly, you have a couple of problems in your keylogger.js file;

    util.inherits(new keylogger, events.EventEmitter);
    exports = keylogger;
    

    You're trying to extend an instance, and your export statement is a bit off. This should work better to export keylogger as an instance which the test file seems to expect;

    util.inherits(keylogger, events.EventEmitter);
    exports.keylogger = new keylogger();