Skip to content
This repository was archived by the owner on Jul 1, 2026. It is now read-only.
This repository was archived by the owner on Jul 1, 2026. It is now read-only.

N-API Support for node-sqlite3 #830

Closed

Description

@sampsongao

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.

Module node-sqlite3 is one of the top 30 native modules by dependency count, and in order to help the Node.js community make the important transition to N-API, we are hoping you will be able to work with us in order to port node-sqlite3 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

Activity

  1. springmeyer commented on Jun 15, 2017

    @springmeyer
    Contributor

    Hello @sampsongao - this is great - thank you for your efforts on N-API. Yes, I would like to support N-API in node-sqlite3. I see you've created ttps://github.com/mhdawson/node-sqlite3/tree/v3.1.4-abi to test the N-API port. How did it go? Was there any performance impact?

  2. sampsongao commented on Jun 15, 2017

    @sampsongao
    Author

    The v3.1.4-abi is the port directly using N-API. But since the N-API is quite verbose, so we also developed C++ helpers to make it simpler to port. I am currently working on porting node-sqlite3 to helpers. And there are some problems I still need to address. Feel free to take a look at the v3.1.4-napi-wrapper branch.

  3. springmeyer commented on Jun 15, 2017

    @springmeyer
    Contributor

    Thanks for the details @sampsongao. Are there any examples of ports of very simple modules you could share as well? For reference our team is planning to work on porting our simple example node module: mapbox/node-cpp-skel#45

  4. sampsongao commented on Jun 15, 2017

    @sampsongao
    Author

    You can take the node-nanomsg port as reference. If you want to take something a little more complex, you can checkout the node-canvas port. Also, take a look on the node-addon-api. That is the wrapper I was talking about.

  5. aruneshchandra commented on Jun 15, 2017

    @aruneshchandra

    @springmeyer - you can tryout the N-API yeoman generator to get started with this https://github.com/digitalinfinity/generator-napi-module.

  6. sampsongao commented on Jul 13, 2017

    @sampsongao
    Author

    @springmeyer How is your experience using N-API is like? We would like to hear your feedback and the obstacle you faced during your migration.

  7. springmeyer commented on Jul 14, 2017

    @springmeyer
    Contributor

    @sampsongao - thank you for the ping. I've not had a chance yet to experiment with the N-API but I will let you know as soon as I do.

  8. sampsongao commented on Aug 17, 2017

    @sampsongao
    Author

    Hi @springmeyer , any update on your experiment?

  9. springmeyer commented on Nov 27, 2017

    @springmeyer
    Contributor

    @sampsongao @aruneshchandra - do you have a branch of latest node-sqlite3 that is working against latest node-addon-api that I can take a look at to learn more?

  10. sampsongao commented on Nov 28, 2017

    @sampsongao
    Author

    @springmeyer You can find it here. https://github.com/mhdawson/node-sqlite3/tree/node-addon-api
    Commands for building and testing should be the same as before.

  11. springmeyer commented on Dec 8, 2017

    @springmeyer
    Contributor

    @sampsongao - thanks, however I hit these errors trying to build that branch: https://gist.github.com/springmeyer/f767c07b662c200121a0296b2fe36a08. Is it working for you? What node version are you testing with? I tried with node v8.9.3 on OS X 10.12

  12. springmeyer commented on Dec 16, 2017

    @springmeyer
    Contributor

    @sampsongao any idea about the above errors?

  13. springmeyer commented on Dec 18, 2017

    @springmeyer
    Contributor
  14. sampsongao commented on Dec 20, 2017

    @sampsongao
    Author

    I am using node master now which is node 10 pre. However, I can't reproduce the problem on my machine and it seems to be node-addon-api related. Can you make sure you are using node-addon-api@1.10.

  15. sampsongao commented on Dec 20, 2017

    @sampsongao
    Author

    Actually, it is problem with std::vector. The assign method is a build in method for std::vector. Do you know any reason vector is not working in X code?

  16. 19 remaining items

  17. jschlight commented on Feb 11, 2019

    @jschlight
    Collaborator

    I'm now actively working on a PR to address this issue. My immediate objective is to apply the commits @sampsongao and @anisha-rohra previously created for this issue to the current codebase up to the point where the libuv dependencies need to be addressed.

  18. jschlight commented on May 13, 2019

    @jschlight
    Collaborator

    At this point I've got nearly all the unit tests passing. I will be working with Michael Dawson to configure my development system to debug the remains failing unit tests.

  19. springmeyer commented on May 15, 2019

    @springmeyer
    Contributor

    @jschlight - great news! Please push up a PR as soon as you have something ready. Thank you.

  20. springmeyer commented on Jun 29, 2019

    @springmeyer
    Contributor

    @jschlight any update on progress here?

  21. jschlight commented on Jul 2, 2019

    @jschlight
    Collaborator

    Michael Dawson and I were able to resolve the issues with my development system. I am able to build and run the N-API module on my development system and run the Mocha tests in lldb. The failing Mocha tests are mostly related to libuv which I'm working to understand. My objective is to see if the dependencies on libuv can be replaced with N-API so that we get full benefit from N-API's stable ABI.
    This process is taking longer than I would like, but I remain committed to seeing it through.

  22. jschlight commented on Jul 12, 2019

    @jschlight
    Collaborator

    The Mocha tests are all passing on my Mac development system, but the AppVeyor and Travis CI operations are filling in the compile process. I'm now investigating why that's the case.

  23. mohd-akram commented on Oct 1, 2019

    @mohd-akram
    Contributor

    I've rebased @jschlight's branch on the latest master and converted the new code added to N-API. I've also replaced the libuv async work code with N-API code. Disabling N-API C++ exceptions helped reveal why some tests were failing which I fixed. Some tests are still failing and there are some random segmentation faults on some platforms if anyone wants to take a look.

  24. jschlight commented on Oct 6, 2019

    @jschlight
    Collaborator

    Thank you so much @mohd-akram for your work on this. I've merged your changes into my fork and resolved a handful of conflicts. I'm now looking into the CI errors.

    Is it possible to see the errors you're getting from Travis CI and AppVeyor for your fork?

    The N-API team meets for an hour each week on Zoom. You are most welcome to join us to answer any questions you may have. You can see the meeting specifics on the Node.js Foundation Calendar under the heading Node.js N-API team weekly meeting. The meeting is currently held on Mondays.

  25. mohd-akram commented on Oct 7, 2019

    @mohd-akram
    Contributor

    You can see the failures here. I was able to avoid the segmentation fault in Node.js 8 on macOS by modifying the Statement::Work_AfterRun method and adjusting its STATEMENT_END macro to exclude the delete baton part. It seems something uses it after it's freed. I'll see if I can join this meeting.

  26. jschlight commented on Oct 7, 2019

    @jschlight
    Collaborator

    Thank you @mohd-akram. I will look at this more closely first thing in the morning.

  27. jschlight commented on Oct 7, 2019

    @jschlight
    Collaborator

    @mohd-akram We discussed your macOS issue during today's N-API Team call. It was suggested that it might help to set visibility=hidden for macOS. The details are under step 4 on this page. This solution was for modules that load multiple times. But it may be applicable here also.

    I'd like to see if we can get to a common codebase. Do you see any issues with me deleting my fork of mapbox/node-sqlite3 and forking off of your project instead?

  28. springmeyer commented on Apr 11, 2020

    @springmeyer
    Contributor

    @jschlight @mohd-akram - what are the next steps on getting node-sqlite3 upgraded to use N_API? If you have something that is close to ready I recommend creating a PR against this repo. Thanks!

  29. mohd-akram commented on Apr 11, 2020

    @mohd-akram
    Contributor

    I've rebased and created PR #1304.

  30. jschlight commented on May 4, 2020

    @jschlight
    Collaborator

    @springmeyer @kewde At the request of the N-API team, I've run some benchmarks on the N-API implementation compared to the NAN version. The results are available here:

    nodejs/abi-stable-node#288 (comment)

    Overall, the node-sqlite3 N-API implementation is running about 15% longer than the NAN version which is not out-of-line with other implementations we've seen.

    I'm now monitoring incoming node-sqlite3 issues. I plan to triage any issues specific to the N-API implementation and make the N-API team aware of any I cannot resolve.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions