Skip to content
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

Update for support node 12 #120

Closed
wants to merge 3 commits into from
Closed

Update for support node 12 #120

wants to merge 3 commits into from

Conversation

fanatid
Copy link
Contributor

@fanatid fanatid commented Apr 27, 2019

Blocked by nodejs/nan#849

Currently only changed to use Maybe version.

@fanatid fanatid changed the title [WIP] Update for support node 12 Update for support node 12 May 7, 2019
@fanatid
Copy link
Contributor Author

fanatid commented May 7, 2019

@rvagg can you check this? secp256k1-node which I maintain need bignum with node12 support

@rvagg
Copy link
Collaborator

rvagg commented May 7, 2019

yeah, doesn't compile for me

This whole addon needs to be converted to node-addon-api but I neither have the time or the expertise to pull that off with any reliability.

@fanatid
Copy link
Contributor Author

fanatid commented May 7, 2019

With this PR bignum building not work for you on node12?

@rvagg
Copy link
Collaborator

rvagg commented May 7, 2019

no, tests segfault with an unchecked Maybe failure leading to an abort

@devsnek
Copy link

devsnek commented May 8, 2019

what if this used js bigints in >= v12, and the native addon in others? that would fix the build issues and probably give perf boosts as well.

@sam-github
Copy link

% git diff
diff --git a/bignum.cc b/bignum.cc
index 9b47ec2..81f9a3f 100644
--- a/bignum.cc
+++ b/bignum.cc
@@ -412,11 +412,12 @@ NAN_METHOD(BigNum::New)
     for (int i = 0; i < len; i++) {
       newArgs[i] = info[i];
     }
-    Local<Value> obj = Nan::New<Function>(js_conditioner)->
-      Call(currentContext, ctx, info.Length(), newArgs).ToLocalChecked();
+    Local<Value> obj;
+    const int ok = Nan::New<Function>(js_conditioner)->
+      Call(currentContext, ctx, info.Length(), newArgs).ToLocal(&obj);
     delete[] newArgs;

-    if (!*obj) {
+    if (!ok) {
       Nan::ThrowError("Invalid type passed to bignum constructor");
       return;
     }

^--- With above patch on top of this PR the tests pass.

@fanatid
Copy link
Contributor Author

fanatid commented May 8, 2019

@sam-github thank you! Updated.

@sam-github
Copy link

devsnek commented 5 hours from now

First time for me seeing time travellers on github!

This is just a drive-through comment, I don't have any dependencies on bigint, but I think @devsnek has a reasonable suggestion. Also, while my patch will unblock this PR if its hurting downstream users, its not in general a good idea to use ToLocalChecked() everywhere, aborting is a pretty harsh penalty for invalid args passed to a js API.

@sam-github
Copy link

@rvagg PTAL

@rvagg
Copy link
Collaborator

rvagg commented May 11, 2019

Sounds like we have a solution. I don't think I'll be in a position to even test this in the next few days so bear with me.

@qix
Copy link

qix commented Dec 3, 2019

@rvagg / @justmoon - This change works for me. Any chance we can get this in an official release?

Thanks!

@fanatid
Copy link
Contributor Author

fanatid commented Dec 3, 2019

While this can be temporary solution, now I agree with @rvagg that addon needs to be converted to node-addon-api. I tried it on previous week and this is nice simple thing, but I'm not sure that I have time for big PR with update everything :(

buu700 added a commit to buu700/node-bitpay-client that referenced this pull request Dec 15, 2019
rvagg pushed a commit that referenced this pull request Dec 20, 2019
@rvagg
Copy link
Collaborator

rvagg commented Dec 20, 2019

pulled and squashed in #124 plus a few additions to get v13 support

@rvagg rvagg closed this Dec 20, 2019
@fanatid
Copy link
Contributor Author

fanatid commented Dec 20, 2019

Thanks!

@fanatid fanatid deleted the node12 branch December 20, 2019 05:43
rvagg pushed a commit that referenced this pull request Dec 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants