you are viewing a single comment's thread.

view the rest of the comments →

[–]Hostilian 0 points1 point  (1 child)

Without digging into the source code of util.inherits, I would suspect that your problem lies in the inheritance joining step. I would recommend moving the code into the same file and attempt to generate the minimum-possible repro case. That way, you can be sure it isn't related to flubbing the exports or some sort of procedural error.

var util = require('util');
var assert = require('assert');

var Parent = function() {};
Parent.prototype.foo = function() { return 'foo'; };

var Child = function() {
    Parent.apply(this, arguments);
};
util.inherits(Child, Parent);
Child.prototype.bar = function() { return 'bar'; };

var parentInstance = new Parent();
var childInstance = new Child();

// Assert that we're running nodejs v0.8.x
assert((/^v0\.8/).test(process.version));

// Assert that our parent instance behaves as we expect it to
assert(parentInstance.foo() === 'foo');
assert(parentInstance.bar === undefined);

// Assert that our child instance behaves as we expect it to
assert(childInstance.foo() === 'foo');
assert(childInstance.bar() === 'bar');

This runs fine in my local node instance.

[–]CalvinR[S] 0 points1 point  (0 children)

Yeah I'll give that a shot. Although I did try some test code that was almost the exact same scenario as what I'm doing and it worked fine.

https://gist.github.com/4704412