Skip to content

N-API Support for node.bcrypt.js #513

Closed

Description

@aruneshchandra

The recently announced Node 8 has a new experimental feature called N-API which is aimed at reducing maintenance cost for node native addons. Checkout this blog for more details on its benefits.

node.bcrypt.js is one of the top 30 native modules by dependency count, and in order to help the Node.js community make this important transition to N-API, we are hoping you will be able to work with us in order to port node.bcrypt.js to support N-API. Your support and feedback is important in making this effort a success.

I am part of the N-API working group and and would like to talk to you about how you can can get started with N-API and what help we might be able to provide. I'm available to talk on the phone individually if you'd like. Alternatively, if you prefer, feel free to jump in our WG meeting which happens every Thursday at 1.30 Eastern / 10.30 Pacific US time, to discuss any issues.

Here’s a video of N-API in action
https://www.youtube.com/watch?v=nmXhJ88nZsk

Activity

  1. recrsn commented on Jun 13, 2017

    @recrsn
    Collaborator

    I tried to get it work. We heavily depend on AsyncWorker but I couldn't find much docs about it.
    And due to other commitments, I could not spend much time on it.

  2. aruneshchandra commented on Jun 13, 2017

    @aruneshchandra
    Author

    You are right there is not a very detailed documentation on AsyncWorker.. however the following header file can help you understand the usage
    https://github.com/nodejs/node-addon-api/blob/master/napi.h#L1362

    Alternatively, do you mind talking to us during our Weekly WG meeting which happens every Thursday at 1.30 Eastern / 10.30 Pacific US time, to discuss some ways we can help you to get started on this port.

  3. self-assigned this
    on Jul 9, 2017
  4. aruneshchandra commented on Jul 13, 2017

    @aruneshchandra
    Author

    //cc @kfarnung - please update the documentation for AsyncWorker

  5. NickNaso commented on Oct 9, 2017

    @NickNaso
    Contributor

    Hi,
    today I completed the porting of bcrypt from NAN to N-API using node-addon-api the code is here https://github.com/NickNaso/node.bcrypt.js/tree/node-addon-api
    All tests successfully pass. Maybe you can consider to integrate the code and with some additional work on documentation and package.json we can publish the N-API version of bcrypt I will be happy to collaborate.

  6. aruneshchandra commented on Oct 9, 2017

    @aruneshchandra
    Author

    //cc: @agathver, @mhdawson, @digitalinfinity

  7. recrsn commented on Oct 9, 2017

    @recrsn
    Collaborator

    Great work @NickNaso

    Please open a PR so that we can continue to iterate there

  8. NickNaso commented on Oct 9, 2017

    @NickNaso
    Contributor

    Hi @agathver
    I think that we need to create a branch so I can execute the PR on it. What do you think?

  9. recrsn commented on Oct 9, 2017

    @recrsn
    Collaborator

    @NickNaso Yes, created a branch called "napi".

  10. mhdawson commented on Oct 11, 2017

    @mhdawson

    @NickNaso thanks for doing this.

    If you don't mind some info on how long it took you (The commits are over 4-5 days) to do the port along with highlighting any things you found more tricky would be good as data for people looking at doing other ports.

  11. NickNaso commented on Oct 12, 2017

    @NickNaso
    Contributor

    Hi everyone,
    I just returned at home I really happy to share my experience on porting bcrypt to N-API
    All the translation process has been taken 5 days of my spare time. In total 10 / 15 hours of work.
    The most difficult task was to create and use AsyncWorker in particular I don't know how to call the callback from the OnOk method but I saw at code here https://github.com/nodejs/node-addon-api/blob/master/napi.h#L1433 and to understand how to better use it I looked at this porting https://github.com/sampsongao/leveldown/tree/napi
    There aren't examples of usage AsyncWorker here https://github.com/nodejs/abi-stable-node-addon-examples
    To understand how to handle the errors I used the examples from the test https://github.com/nodejs/node-addon-api/blob/master/test/error.cc
    As reference I followed the N-API documentation here https://nodejs.org/dist/latest-v8.x/docs/api/n-api.html
    It was not very difficult but with more useful documentation could be more simple and fast.

  12. NickNaso commented on Oct 17, 2017

    @NickNaso
    Contributor

    Hi,
    today I updated the code and just fixed some compilation error that I received on Windows platform and now all work fine on macOS - linux - Windows with Node.js version 8, but in Node.js version previous the 8 the module is compiled well but I receive an error when I require it.
    Just post an example
    node-v7 10 1

  13. digitalinfinity commented on Oct 17, 2017

    @digitalinfinity

    Hi @NickNaso to clarify- you're using the binary that was compiled against NAPI as implemented in Node 8.6+? On downlevel, I believe the story is you need to use the node-addon-api package for compat with old node versions. Which version of Node do you get the above error in?

  14. 10 remaining items

  15. mhdawson commented on Jan 30, 2018

    @mhdawson

    @agathver thanks!

  16. recrsn commented on Apr 6, 2018

    @recrsn
    Collaborator

    @NickNaso node-pre-gyp has got napi support. Will you be willing to contribute a patch adding it to the napi branch?

  17. NickNaso commented on Apr 6, 2018

    @NickNaso
    Contributor

    @agathver I will do it in this weekend and I will open a PR on napi branch.

  18. NickNaso commented on Jan 24, 2019

    @NickNaso
    Contributor

    Hi @agathver,
    I worked on porting the updates on the NAN version of the add-on to the N-API release. I added the support for node-pre-gyp.
    Please when you have time see the PR: #698

  19. NickNaso commented on Feb 18, 2019

    @NickNaso
    Contributor

    Hi everyone,
    Is there a plan to switch to N-API for this module? In case how can I help?

  20. recrsn commented on Mar 8, 2019

    @recrsn
    Collaborator

    The plan is to maintain both versions of the module for now, till Node 8 remains supported.

  21. NickNaso commented on Mar 8, 2019

    @NickNaso
    Contributor

    Ok I will try to maintain the N-API version in sync with the classical version.

  22. DRoet commented on Oct 26, 2019

    @DRoet
    Contributor

    Any plans for a 4.x.x release that uses N-API by default? now that node 8 is almost EOL.

  23. recrsn commented on Oct 29, 2019

    @recrsn
    Collaborator

    That's on the roadmap for this November.

  24. self-assigned this
    on Oct 29, 2019
  25. recrsn commented on Feb 19, 2020

    @recrsn
    Collaborator

    bcrypt is now using N-API by default

  26. mhdawson commented on Feb 19, 2020

    @mhdawson

    @agathver thanks for the update !

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions