Node 0.12.0 and native add-on modules

15th February, 2015 — Aral Balkan

TL; DR: If your Node projects depend on native add-on modules, they might break in Node 0.12.0. Make sure the latest versions of your dependencies have been updated to support the version of the V8 engine in the latest stable version of Node.

Now that Node 0.12.0 stable is out, I’ve updated all our projects to run on it, including Heartbeat’s node component, the main site, and projects like Set.

In a nutshell, it has been a seamless experience save for one issue that bit me every time: native add-on module failures.

I initially ran up against it in Heartbeat, with the bufferutil dependency of the ws module.

dyld: lazy symbol binding failed: Symbol not found: __ZN2v86Object3SetENS_6HandleINS_5ValueEEES3_NS_17PropertyAttributeE
  Referenced from: /Users/aral/Library/Developer/Xcode/DerivedData/Heartbeat-bwptofoniwaoqzcgkxzhjtbmtjak/Build/Products/Debug/Heartbeat.app/Contents/Resources/node.js/node_modules/ws/node_modules/bufferutil/build/Release/bufferutil.node
  Expected in: dynamic lookup

dyld: Symbol not found: __ZN2v86Object3SetENS_6HandleINS_5ValueEEES3_NS_17PropertyAttributeE
  Referenced from: /Users/aral/Library/Developer/Xcode/DerivedData/Heartbeat-bwptofoniwaoqzcgkxzhjtbmtjak/Build/Products/Debug/Heartbeat.app/Contents/Resources/node.js/node_modules/ws/node_modules/bufferutil/build/Release/bufferutil.node
  Expected in: dynamic lookup

I updated it to the latest 0.7.1 version (I was on 0.4.x) but that didn’t fix the issue. Updating it to the latest version via the Github repository, however, solved the problem:

Package.json {
  ...
  "dependencies": {
    "ws": "git://github.com/websockets/ws.git",
    ...
  },
  ...
}

(Which is odd, as I can’t see what in the commits since the 0.7.1 release would address the issue. I’m left wondering if there was another variable also that gave me a false negative with 0.7.1.)

I then ran into a similar issue when updating Set:

dyld: lazy symbol binding failed: Symbol not found: __ZN2v86Object3SetENS_6HandleINS_5ValueEEES3_NS_17PropertyAttributeE
  Referenced from: /Users/aral/ind.ie/projects/labs/node_modules/indie-set/node_modules/jsdom/node_modules/contextify/build/Release/contextify.node
  Expected in: dynamic lookup

dyld: Symbol not found: __ZN2v86Object3SetENS_6HandleINS_5ValueEEES3_NS_17PropertyAttributeE
  Referenced from: /Users/aral/ind.ie/projects/labs/node_modules/indie-set/node_modules/jsdom/node_modules/contextify/build/Release/contextify.node
  Expected in: dynamic lookup

This time with the contextify dependency in JSDOM. I was using a rather old version (1.0.3).

I ran npm shrinkwrap on Set and then rm -rf node_modules, followed by npm install.

That failed with:

> contextify@0.1.9 install /Users/aral/ind.ie/projects/set/source/node_modules/jsdom/node_modules/contextify
> node-gyp rebuild

child_process: customFds option is deprecated, use stdio instead.
  CXX(target) Release/obj.target/contextify/src/contextify.o
../src/contextify.cc:34:17: error: no member named 'ContextDisposedNotification' in 'v8::V8'
        v8::V8::ContextDisposedNotification();
        ~~~~~~~~^
1 error generated.
make: *** [Release/obj.target/contextify/src/contextify.o] Error 1

Again, updating JSDOM to the latest version (3.1.1) fixed the problem.

Although I was lucky in those two instances, unfortunately, not every native add-on module has been updated for Node 0.12.0 yet.

I got bit by the Gaze module, for example. Although you’ll be fine if you’re using the non-native (and recommended) 0.5.1 release from NPM, I was running the latest 0.6.4. The solution there was to revert the project to using the 0.5.1 release.

So, all this to say, unless you’re happy learning the intricacies of wrapping C++ objects, check that the native add-on modules you are using in your project have been updated to support Node 0.12.0 before you take the plunge.