-
-
Notifications
You must be signed in to change notification settings - Fork 814
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
Support Node 0.11.4 #184
Support Node 0.11.4 #184
Conversation
Hi @kkoopa - thanks for the pull. Looks like you've put a lot of effort into the nan project. As I mention in #180, I plan to take a review the v8/node c++ changes once node v0.12.x is out. At that time I will review your pull and decide whether nan is appropriate. In the meantime, a few thoughts:
|
Yes,the idea is to have it as a module configurable exactly like that. This will come in the near future, at latest when 0.12 arrives. I have not benchmarked this, as I haven't tried it on other platforms than Linux, and I only have a VM available, which does not seem to offer a realistic benchmarking experience. I did however do some benchmarking of hiredis-node redis/hiredis-node#40 (comment) and it showed no performance regressions. And from theory I can state that performance on old versions will be equal or better, as all of NAN is a set of conditional macros and inline functions. |
test TryGhost#184 on Travis CI version of Node 0.11
As mentioned in kkoopa#1 it does not work on 0.11.0 < Node < 0.11.4, as they are outdated development releases and there is no point in supporting them. It works on 0.11.4+. Travis is still stuck at 0.11.3. |
NAN is available through NPM now. |
@kkoopa - I'm planning on taking a closer look at this patch in the coming weeks. Any updates you see as needed based on more movement in node core or NAN? |
Updated NAN dependency to 0.4.1, which is the latest. Node 0.11.8 or should arrive at some point, but this builds with latest HEAD. There have been some deprecations in v8, so expect a new minor NAN release for 0.11.8. |
yes please! I'd like to start being able to benchmark on 0.11. |
@rvagg Could you please explain what the benefit of making nan a dependency of this module would be? I'm not seeing large amounts of dropped code; mostly just wrapping existing callbacks. |
You're looking at it from the wrong side, it's about not having large amounts of duplicated code. |
Sure, but this module wasn't using nan before, and your pull request adds it. Yet, there's no removed code? |
As explained in the commit message and #180, #151 and #177, the current version of node-sqlite3 does not work and will not work on anything newer than Node.js v0.10.x. That currently excludes the 0.11-series, which will become the 0.12 series in a couple of months. When 0.12 is released, all further development of 0.10 will stop. The reason it will not work is because a significant part of the API in v8 has been changed in an incompatible way. As some people like to use outdated software, which might be legitimate due to stability concerns, this causes a problem for native addon developers, as their codebase suddenly has to support two very different platforms. The three basic options are then: support the outdated platform and lose all users with current versions, support the new platform and ignore the old production users, or make and maintain two separate versions for each group. The best solution is actually none of these, it is wrapping all incompatible functions in an abstraction layer, unifying the two disjoint architectures and maintaining one version of the code, supporting both. This pull request offers supporting both architectures without code duplication. |
To see why NAN is useful, consider these two snippets that do exactly the same thing, i.e. declare a method to expose to JS, but one is for Node 0.10 and prior and the other is for 0.11 and onwards: Node 0.10 and prior: v8::Handle<v8::Value> DoSomething (const v8::Arguments& args) {
v8::HandleScope scope;
// ...
return scope.Close(v8::String::New("We did something"));
} Node 0.11+ void DoSomething (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HandleScope scope(isolate);
// ...
args.GetReturnValue().Set(v8::String::New("We did something"));
} It would be difficult to be more different! The V8 team decided to do some major API reworking and that's been bleeding into Node since around 0.11.3. NAN is all about making it unnecessary to have macro branching in your addon code just so you can support the different versions of Node that you want. NAN tests from 0.8 up to Node master and we're always adding new stuff as more V8 breakages come in. There's also some Node breakages that we smooth over too, currently this is mainly for The idea is that you include nan.h and code against the NAN API which provides a very thin layer (mostly macros) between your code and Node + V8 but it takes care of compatibility for you and will continue to take care of it as V8 and Node evolve. The alternative for Node 0.11/0.12 is going to be to drop support for 0.10 and prior or have the code full of The NAN version of the above code is this: NAN_METHOD(DoSomething) {
NanScope();
// ...
NanReturnValue(v8::String::New("We did something"));
} This expands out to be whatever the target version of Node/V8 is wherever it's being compiled. |
Also, more directly answering the question about why pull it in as a dependency: the initial versions of NAN just distributed a header file that you put in your project and distribute yourself but now we're distributing it via npm so you don't need to have your own copy, you just pull it in via npm and compile against it. If you pin the dependency as I believe the initial version of this pull request had nan.h embedded but that's gone now in favour of having it as a dependency. |
nan is a very good thing if your goal is to support node 0.10 and 0.12 (when it lands). Without NaN you would either be in |
Okay, thanks @rvagg for explaining the rationale behind this pull request. This all makes sense. |
thank you @rvagg for your clear explanation of nan and how node 0.11.x is a potential nightmare for the "native modules" ecosystem in npm. @springmeyer can you share your opinion on this and do you have an idea where this could fit in the node-sqlite3 roadmap ? I am investigating the use of the new koa.js - http://koajs.com/ framework written by the main contributors of express.js but it only works with node 0.11.9 at this stage so I have to either go without koa.js or without node-sqlite3 which is tearing me apart ;-) note that I only use "build-from-source" with node-sqlite3 so in my case I don't need a precompiled node-sqlite3 working with node 0.11.x but only the patched source code using Nan. as a side node, nan was apparently accepted on node-postgres (commit by @rvagg ) here - brianc/node-postgres@f58ff73 |
For information i tried the following today (I am using sqlite 3.8.1):
and get :
The same steps work perfectly with
I looked around a bit but have a hard time understanding what goes wrong. @koopa what are your steps to compile node-sqlite3 with 0.11.9 ? Thank you |
My initial guess is that your custom sqlite3 build is linking with gcc rather than g++. |
Looking into this (the hard way I am not a link expert ;-) regarding the warning on "typedef internal::Internals I;", I don't think it is part of the problem. This warning is pretty explicit in the v8.h code for this version of node
The typedef has been removed from v8 trunk : https://code.google.com/p/v8/source/browse/trunk/include/v8.h#5789
now back to the missing symbol. it seems to me that g++ is used by node-sqlite3 at link time ; can it really depend on my sqlite3 custom build (a pretty standard sqlite3 build configure/make/make install) ? |
@jeromew - thanks for helping test and push this forward.
I plan to 1) upgrade the bundled libsqlite3 version, 2) merge this, and 3) migrate the binary build system to node-pre-gyp when I find the time. I'm fully on board with using NAN and I am very thankful for the work put in to make it available. I anticipate I will be able to do this sometime in the next couple weeks. |
Hello. Here are the results of my research on this. Maybe @kkoopa or @rvagg you can take a look at these results. There is something weird somewhere that I don't understand. Long story short : 1.the missing symbol is _ZN2v87Integer3NewEi
3.but cannot be found in node v 0.11.9
4.instead we find this symbol _ZN2v87Integer3NewEiPNS_7IsolateE 5.different hints lead me to this block of code in v8.h
6.it appears that only an "Isolated" version of New(uint32_t) exists in nvm node 0.11.9 7.I could not find any Nan helper that handles this case 8.note that the signature (int32_t, Isolate_) is reversed from NanNewLocal (Isolate_, Local) 9.the compilation works if I add to Nan something like
10.and modify the node-sqlite3 code with
11.result: no more missing symbol at built time
12.but this is not the end of the story
13.this probably belong to source->IsRegExp() and args[start]->IsRegExp() of statement.cc 14.this time less luck with nm
15.and
So IsRegExp does not seem to be exported. I have learned a lot of things doing this but I am a bit stalled understanding why those symbols are not in the binaries given by "nvm install 0.11.9" (http://nodejs.org/dist/v0.11.9/node-v0.11.9-linux-x64.tar.gz) 16.losing hope I tried to compile node 0.11.9 from the sources
17.and now ... everything works like a charm !! all tests passing green straight from @kkoopa's branch :-) I knew "node.js" was bleeding edge so I am the only one to blame for spending so many hours on this ;-) but if you can help me understand what is going on here I will be grateful !! Can we fix something so that these symbols get exported in the official node.js binaries or is it best practice to always compile node.js from source when using native extensions ? |
Just for simplicity, the issue I created will lead you to another open issue on node.js. There is indeed a problem on the pre-packaged binaries and they are looking into it. so until they fix this issue and if you want to test @kkoopa's branch on 0.11.x, compile node.js from the source and do not use pre-packaged versions |
@kkoopa - I've finished a bunch of packaging work (#245) and tagged v2.2.0. Next thing on my mind is testing your patch and getting it merged. Let me know if you might have time to update the branch (and ideally squash to a few commits), otherwise I can take a look at doing this when I have time (est 2-3 weeks). |
For node < 0.10, some dependencies cannot be solved. We really don't care. For node >= 0.11, it seems that there are problems with sqlite3 extension. Didn't dig much, but may be related: TryGhost/node-sqlite3#184
This has now been merged! Node-sqlite >= v2.2.4 will now support node >= v0.11.13 and above thanks to the hard work of the Nan contributors. |
To clarify: as of nan@1.0.0 we removed support for all 0.11 versions prior to 0.11.13, the changes were too traumatic to maintain anything else. 0.8, 0.10 (and even 0.6 I believe) are all fine though. |
@rvagg - sounds good. Edited my statement above to clarify. |
Maybe README.md needs to be updated then? |
@Mithgol thanks! At last it is possible to use it with recent node-webkit! Will try to migrate this evening :) |
@Mithgol thank you very much, I will follow up |
@Mithgol - So are we OK to build for NW 0.9.2? I still got plenty of errors ... |
@gpetrov No, it's not OK to build for NW 0.9.2. Node-webkit v0.9.2 is based on Node.js v0.11.9, and that version is not supported by node-sqlite3. In the v0.11.x branch of Node.js we support only v0.11.13 and newer (that's what nan@1.0.0 does as @rvagg explained in a comment above). It's likely that node-webkit 0.9.2 is not to be supported by node-sqlite3 at all. |
P. S. Currently even a support for node-webkit 0.10.0-rc1 requires installing node-sqlite3 from the experimental (That branch is likely to be eventually landed to the |
@Mithgol Yes I found that out the hard way. However node-sqlite3 has just landed version 2.2.4 which should build just fine in node 0.11. However nw-gyp is now giving problems nwjs/nw-gyp#32 Hope @rogerwang will solve them soon |
This is a backwards-compatible patch for Node 0.11.4+. It addresses #180 #151 #177. Travis is still stuck at 11.0.3, so it does not compile there.