Initial 0.11 compatibility attempt, using new project: NAN #48

Merged
merged 6 commits into from Aug 11, 2013

Conversation

Projects
None yet
5 participants
Owner

rvagg commented Jul 20, 2013

Node 0.11.4 introduced V8 3.20.2 which has a crazy amount of breaking API changes, maintaining compatibility across versions is a tricky prospect but I've been hacking away at a solution for cross-version compatibility for a little while now; I need it for a few native addon projects.

So say hello to NAN ( Native Abstractions for Node.js): https://github.com/rvagg/nan, which is really just a header file that can be included in a built and provide all the necessary abstractions to get 0.8, 0.10 and 0.11/0.12 compatibility without having to do any version sniffing yourself (in theory!).

This compiles and runs for me on Linux for 0.8. 0.10 and 0.11.4, I haven't tested any other platform and I worry about Windows... Previous versions of 0.11 won't work, there are incompatibilities that can't be tested because they haven't been incrementing NODE_MODULE_VERSION.

Note that if you get this running in 0.11 and run the LevelUP tests against this then you'll get a couple of failures:

  • a setTimeout problem caused by this Node bug that's impacting slow-stream but that's only for testing and that should be fixed in 0.11.5.
  • an sparse Array problem caused by this V8 bug (found thanks to LevelUP + Node 0.11!) in the tests that make big blobs of data using the Array.apply(null, Array(1024 * 100)) trick. Just reduce that 100 to a 90 and it'll run.

Would appreciate anyone who wants to have a play and look over the code. I'm happy to answer any questions anyone has on what I've done and even happier if anyone can find problems in what I've done.

Also relevant:

i.e. there may be an "official" solution to this problem, but I don't have the patience to wait for it—it's not likely to appear until much later in the 0.11 cycle because it'd be no small job, and I had this in progress anyway so I just finished it off.

Owner

mcollina commented Jul 20, 2013

This is impressive. Congrats.

Owner

No9 commented Jul 20, 2013

@rvagg windows build seems to be looking for 1.10.0 :(
Looks like its going to be a long night.
Will post my findings here

rvagg referenced this pull request in Automattic/node-canvas Jul 21, 2013

Closed

0.11.4+ compatibility using NAN #305

Owner

rvagg commented Jul 21, 2013

actual nan.h was missing from the original PR (it was a symlink), commited it now, upgraded to 0.1.0

Owner

kesla commented Aug 4, 2013

@rvagg Wouldn't it make sense to merge this in sooner rather than later? So that all future development is based on this version rather than the old version...

kesla referenced this pull request Aug 4, 2013

Closed

Use abstract-leveldown #50

Owner

juliangruber commented Aug 10, 2013

merging this in now would be totally rad, then I can use level-co!

Owner

kesla commented Aug 10, 2013

I've cherry-picked some commits from #50 so that we're having the latest version of nan in this PR.

There's sadly a test failing from time to time, so right now that's keeping us from being able to release this. I'm looking at it right now, and I'll let you know if I'm making any progress :)

Owner

juliangruber commented Aug 10, 2013

👯

kesla referenced this pull request in Level/abstract-leveldown Aug 10, 2013

Merged

Add test to get() multiple times - both found and not found keys #15

Owner

kesla commented Aug 10, 2013

Alright, so some progress!

I found that it's actually .get() that is failing, not .batch() - it's the .batch-test that uses .get.
I've narrowed it down to https://github.com/rvagg/node-leveldown/blob/node_0.11_compat/src/async.h#L32 not working as expected, the c-string is not persistent and can be written over when there's other things going on...

Pull request fixing this coming up, but @rvagg I'm counting on you keeping track on me :)

Owner

kesla commented Aug 10, 2013

@rvagg Please take a look at the change that I did to get this to work, especially since it's involves a change in semantics to nan - maybe there's another way to fix this that doesn't involve the change to nan?

Owner

kesla commented Aug 10, 2013

Hm...

When running the tests on node 0.11.4, not all tests are run... Am I the only one experiencing this? https://cloudup.com/c4tpJ1AgY0f

I've tried running the tests with plain node, like node test/del-test.js with the same result.

Owner

juliangruber commented Aug 10, 2013

maybe tap has problems

Owner

juliangruber commented Aug 11, 2013

except for a test that already failed in node 0.8.x, the tap testsuite passes on 0.11.4 on my mac.

@rvagg rvagg added a commit that referenced this pull request Aug 11, 2013

@rvagg rvagg Merge pull request #48 from rvagg/node_0.11_compat
Initial 0.11 compatibility attempt, using new project: NAN
f77b4e4

@rvagg rvagg merged commit f77b4e4 into master Aug 11, 2013

1 check passed

default The Travis CI build passed
Details

rvagg deleted the node_0.11_compat branch Aug 11, 2013

Owner

rvagg commented Aug 11, 2013

@0.7.0 in npm, let the world rejoice, I'll do a corresponding levelup & level now that'll pull them in. new abstract-leveldown is published too.

Owner

rvagg commented Aug 11, 2013

@No9 all good for me on Windows 0.10.5, I haven't bothered testing 0.11 but would love to hear your reports if you're testing 0.11.

Owner

kesla commented on 4112961 Aug 11, 2013

Hey @rvagg, now that leveldown 0.7 has been released I guess that you approve of this change to the semantics of nan.h? Do you want me to do a PR against nan adding the change from here or do you take care of it yourself?

Owner

rvagg replied Aug 11, 2013

tbh I didn't notice this but could you put a PR against NAN for me? then at least there's more eyes with smarter C++ sense than me looking at it. Thanks!

Owner

kesla replied Aug 11, 2013

No problems, there was quite a lot of changes done in there...

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