Open mhdawson opened 6 years ago
@groundwater I was hoping you might be interested in this, wondering if you go the ping through @nodejs/delivery-channels
Thanks for CCing. We NW.js maintainers would like to keep an eye on this. Though we just released NW.js 0.30.1 with Node.js 10.0.0 within 24 hours, rebasing with latest Node.js is still a significant effort. We are interested in this topic on how to integrate Node more easily.
@rogerwang thanks for replying, will include you when we get things rolling
Hi @mhdawson. Thanks for this! We have a number of folks at JSConf EU, and I believe there is a node's summit occurring shortly beforehand. Would it be worth sending a few of our folks to kick this discussion off in-person?
I think having folks at the summit would be awesome!
On Fri, Apr 27, 2018, 11:53 AM Jacob Groundwater notifications@github.com wrote:
Hi @mhdawson https://github.com/mhdawson. Thanks for this! We have a number of folks at JSConf EU, and I believe there is a summit occurring shortly beforehand. Would it be worth sending a few of our folks to kick this discussion off in-person?
— You are receiving this because you are on a team that was mentioned. Reply to this email directly, view it on GitHub https://github.com/nodejs/user-feedback/issues/51#issuecomment-385013637, or mute the thread https://github.com/notifications/unsubscribe-auth/AAecV7sxNVOg_xqfGPx2b0LqaasSzJ4dks5tsz79gaJpZM4TSdYW .
Hello, yesterday i enabled the --shared
flag on node 10 debian package. Worked perfectly and this is really cool. I think make install
should continue to install the executable (the one linked to the built lib) though.
Not yet ready on my side, but it's going to bring a lot of improvements with respect to packaged addons, and multiarch support in debian. I'll follow up on issues tracker if necessary. I wish i could share my enthousiasm regarding how nodejs has matured and is getting easier and easier to distribute...
@groundwater I don't necessarily want to wait to start discussing and possibly meeting remotely until after the summit (not everybody will be at the summit either), but getting together in person at the summit would be great.
@mhdawson agreed. Would you like to kick this off asynchronously or via a synchronous video discussion?
I’d definitely like to be involved in this, yes.
Also, maybe /cc @fs-eire … please let me know if this is not the kind of thing you want to be pinged in, but it sounded like you might be somebody who wants to be aware that this is happening?
I think starting with a video call to get together to review what I suggested above as the way forward and to agree on the best way to work together (github, regular meetings or whatever). I'll get together with @yhwang to set up a kickoff meeting.
@gireeshpunathil FYI.
We currently embed the shared library in IBM Integration Bus, we recently updated in quick succession from node 4 through 6 to node 8 and found the upgrade process pretty painful so anything we can do to help stabilise the interfaces or improve our own integration would be a benefit to us.
We are a bit unusual in that we also embed a JVM and on windows platforms a CLR as well so we may have some use cases / problems that other users do not so might bring some different use cases to the table.
@davicrig sounds good, your insight will be valuable.
With @mhdawson help, we plan to have a conference call to discuss about the shared lib usage and try to form the group for embedding users. Here is the agenda:
================================
Feel free to add item into the agenda for discussion.
I created a doodle poll for the conference call ==> https://doodle.com/poll/tamxygwfsgh5dr5w. Please select your available time slots then we may select a proper time for the conference call once the most people who are interested in vote.
@gabrielschulhof adding you as an FYI as from your comments in a different issue I'm hoping you are interested in participating here as well.
Hey, just letting you know that there's a project that embeds .NET in Node but also the other way around. Perhaps it can provide some additional usage context. https://github.com/tjanczuk/edge
I'd like to add that https://github.com/janeasystems/nodejs-mobile is a project that allows you to embed node into Android/iOS application; Jaime @jaimecbernardo, might be interested in this; as I believe it would simplify updates if this was a consistent interface.
@addaleax if you can make one of the proposed times can you fill out the doodle?
@groundwater can you fill out the doodle?
@rogerwang can you fill out the doodle?
Hi, in debian, it's considered to be "the right thing" to build (independently packaged) node addons against libnode-dev. I've enabled this with nodejs 10 debian package (which is sitting in experimental right now because many addons are still not compatible with node 10). This to emphasize shared lib builds are not only useful for embedders, but for distributors as well.
@kapouer are you talking about node.js as a shared library or things like openssl. The topic of this thread is the former.
@mhdawson node.js as a shared library (which is as you point out, linked to other shared libs in debian).
@kapouer I guess the libnode64
contains shared lib and libnode64-dev
contains the header files. So distributors also care about the shared lib build as embedders. Thanks for the information.
The poll result is 15:00 - 16:00 UTC/GMT this Thursday (17/May). Look forward to talking with you then. I will send out the invitation later.
Doodle was closed. Will try to attend on Thursday.
@rogerwang sorry for that and welcome to join the discussion on Thursday. And here is the zoom that we will use for the meeting: https://zoom.us/webinar/134723812
I'll be there :)
Great! I'll join the meeting on 17th May.
I'll join on Thursday.
I will also join the meeting on Thursday, Thanks!
Me and @orangemocha from https://github.com/janeasystems/nodejs-mobile will also be joining on Thursday. Thank you!
We got dropped because another community meeting was started I think. Sorry for that. Thank you for joining the discussion.
I’d suggest creating a @nodejs/embedding team with everybody from today’s call in it, mostly as a way of being notified about relevant PRs/APIs. Does that sound okay? Alternatively, we could create the team and add a list of people who explicitly opt-in, if we’d expect it to be too much noise for some people.
My observation from the first meeting is: potentially there are two ways to consolidate the embedding story:
The problem with the first approach is that the relevant re-enterable constituents (Platform, Environment, Isolate, libuv and Conetxt?) are singleton at the moment, so we don't know which of those are capable of recycling and re-entrance at the moment. Unless we test those through different uss cases we don't know the level of isolation they possess to the external world and between themselves.
So I propose we compile the existing and potential use cases as the first step, ratify their relevance, prioritize their impact and then address those in core through refactoring.
Scenarios that I am aware of:
Control flow:
Non-JS workload wanting to leverage Node.js for async I/O
JS workload wanting to leverage Node.js' existing v8 instance for re-use
Behavioral control of Node.js' stdios similar to child process spawning
Behavioral control of Node.js' signal handling from the embedder
Behavioral control of Node.js' exit handling from the embedder
Composition: [ I see many types of compositions are available when building from source, this covers the binaries that can be shipped ]
+1 to @gireeshpunathil's suggesion. I think capturing/documenting the use cases will provide a strong foundation to start with.
@mhdawson @gireeshpunathil I think that's why we need the input from user perspective. Embedding users have their pain points and actually they also have their workaround. We should work together to integrate their solutions or enhance the node.js and make a better embedding experience.
@addaleax @nodejs/embedding
is great. Can I create it?
@gireeshpunathil thanks for your input. we should put it into the use cases/pain points document.
I happened to have a family event after the meeting and just came back now. I will start to consolidate everyone's inputs in the meeting.
For @orangemocha, @jaimecbernardo, @alexeykuzmin, @nitsakh, @rogerwang, @fs-eire, @codebytere, @deepak1556 and @tdolby, can you provide your use cases and pain point in the comment and I will try to consolidate your input. Thanks.
@addaleax
@nodejs/embedding
is great. Can I create it?
Sure, go ahead! If you can’t create teams because you’re not an org admin, just let me know.
@yhwang In NW.js we
node.exe
on Windows. It would be better to depend on something like node.dll
.@yhwang , from the perspective of nodejs-mobile:
node::Start
as the main entry point of the library, for use in native apps. We also ship plugins for Cordova and React Native that provide additional facilities both at build time and run time.Challenges / pain points:
require
a lot of small .js files, each with a synchronous round trip to a storage device. It is dramatically apparent on devices with slower storage drives. https://github.com/dominictarr/noderify is currently saving the day. I would love to see something like that make its way into Node core. @orangemocha - interesting scenarios!
Note that on iOS we are now allowed to spawn Node in a separate process.
did you mean not
as opposed to now
?
however there are many places in Node and libuv where those are assumed to correspond to file descriptor 1 and 2.
can't we solve this by simply redefining console.log
and console.error
and piping them to the desired streams before entering app code, or is it more complex than that?
@gireeshpunathil
did you mean not as opposed to now?
Yes :) Edited inline. Thanks.
can't we solve this by simply redefining console.log and console.error and piping them to the desired streams before entering app code, or is it more complex than that?
That is certainly feasible, and probably a fine solution. Currently we are redirecting the underlying process.stdout/stderr streams, but I have no knowledge of use cases out there that depend on those.
Background
IBM Integration Bus is an Integration Platform provides a graphical programming environment for connecting disparate systems including transformation, enrichment, enhancement etc of inflight data flowing between these systems. User built applications are executed on a native C++ server process that also embeds a number of specific language runtimes (Java, .NET (on windows), nodejs.
Functional Use Cases
We embed the node.js engine to allow customer access to integration points that are accessible via node.js libraries. For example using the loopback framework. This includes marshalling / unmarshalling the data between our internal "message tree" format and javascript datatypes.
Executed node.js should be able to take advantage of the full JS ecosystem including modules that may have native dependencies.
Node dependencies are configured offline to deployment of the application using npm / node-gyp run in an external node process (ie/ the executable not the shared library.)
Building/Testing use cases
In order to support internal regression testing we also require the facility to execute arbitrary javascript code executed on the embedding node.js runtime (for example to test our integration layer and to provide integration testing on our connectors).
In order to support internal unit testing we test our own customer javascript using the usual frameworks chai / sinon etc and execute tests of pure JS code from an external node process.
We require code-coverage for our customer JS code and fail builds the reduce code coverage.
For the dependencies that we ship we run npm and by extension node-gyp as part of the build process.
Pain Points
The lifecycle of our major versions is much longer than the node.js lifecycle therefore we need to make major version updates within our release cycle. We have recently completed upgrade from node 4 to 6 and are in the process of moving to 8. In each case instability in the v8 API has lead us to need to rework the code which interfaces between the node.js engine and our C++ runtime.
Providing a stable API for embedding to would relieve the need for us to do this rework.
As part of an upgrade one of the significant issues we had was finding a way to ensure that our dependent node modules for both build and test were rebuild / recompiled with node-gyp, although this might belong in a different discussion we found that instability in many of the test framework APIs resulted in us having to make minor refactors to huge numbers of tests.
On windows we need to delay load the shared lib because native modules built by both the connectors that we ship and potentially user defined connectors contain the node executable name in their symbols. In order to prevent users having to recompile their modules just to work with us we needed to use dumpbin to export all the node executable symbols and redirect them to our own lib which we then chain to the shared lib.
Being able to remove this would remove considerable complexity to our build.
Since we are embedding the engine we expect to control the lifecycle of the node engine itself and any event loops / handles etc so that we can shutdown cleanly. During the upgrade to newer node versions we found that the shutdown process we were previously using did not work correctly. We eventually found that there were ways around this but a lack of documentation on object lifecycle made this very difficult for us.
Because we ship a JVM we have a reliance on certain signal handlers registered by the JVM and we have seen in the past that some node version register for -3. This in particular is problematic because this signal is used by the JVM to produce a javacore / heapdump which can be essential to diagnose problems in user supplied java code. We would ideally like the signal handlers used by the embedded node runtime to be documented and if possible have some more flexbility on which set of signals are used (for example something along the lines of https://www.ibm.com/support/knowledgecenter/en/SSYKE2_7.0.0/com.ibm.java.lnx.70.doc/diag/appendixes/cmdline/Xrs.html)
The node.js runtime is pretty opaque to us so we are not able to provide our users much operational information around the node runtime. For example we cant display how busy the event loops is, what the memory usage of the node engine is etc which means we do not have administrative feature parity with our other embedded runtimes.
We note that OpenSSL is statically linked to the node.js shared lib which makes the symbols available to the runtime loader on linux. Since we also ship OpenSSL (and consume other libraries which in term use OpenSSL) we are in a position where our code may end up using the node-provided symbols. If the OpenSSL versions differ between node.js and what we ship or if different global variables that share a name this can cause unknown behaviour. We increasingly have a need to update OpenSSL frequently to allow customers to mitigate exposure to high profile SSL attacks and we have imposed timelines on being able to make these upgrade. Decoupling from node version would help us significantly.
Having a long support lifecycle for a major version (minimum of 8 years) also puts us on a compiler upgrade treadmill if we want to maintain node currency especially on Visual Studio where we need to distribute additional runtime versions and where load-time binary compatibility between compiler versions seems to be weaker than gcc.
@gireeshpunathil also mentioned different icu options, we have seen similar symbol clashes with other third party binaries involving icu and our preference is for icu to be privately namespaced in a library.
@yhwang we should probably start planning the next meeting.
FYI @codebytere. @rubys is starting to get this started again (taking over from @yhwang). From your the presentation at the collaborator summit it sounds like you would want to be involved.
In my case I am building a high performance FaaS (Function as a Service) called MetaCall (https://metacall.io). For me it was necessary to have embedding API for NodeJS. But as it was not possible I managed to solve it myself.
I have add a detailed post in another issue (https://github.com/nodejs/node/issues/23265#issuecomment-452690239) detailing how I have achieved it. With the MetaCall library you can easily embed NodeJS in any language (not just C/C++).
I leave here the link to the repository (https://github.com/metacall/core). It may be interesting for NodeJS devs or other people looking to embed NodeJS.
@rubys would be great to move the formation of this group forward.
Hi @mhdawson ,
I've been doing some node embedding and development in my free time, focusing on integration with native C++ apps (and thereby using node-addon-api as well). I'm highly interested in where this goes, so I've subscribed to this issue. Is there anything else you would recommend I do so I can stay in the loop regarding node embedding and API changes? Not sure what this group is you mentioned, but I would love to contribute in any way possible (inputs for use-cases, testing apis, feedback, etc)
Thanks, Kevin
@Kevin thanks for the heads up. @rubys is away for a few weeks but when he gets back we'll see if we can get this initiative going again and then point info on participation in this issue.
There is ongoing work to allow Node.js to be built as a static or shared library. This allows Node.js to be embedded in the process of another application. See https://github.com/nodejs/node/issues/14158, which is also being backported to 8.X and 6.X (https://github.com/nodejs/node/pull/19047, https://github.com/nodejs/node/pull/19050).
@yhwang is currently working on adding testing to the CI. That testing, however, will just be to make sure that the existing Node.js tests cases pass when using the static/shared library.
After that, we will want to add testing that covers typical use cases related to embedding Node.js into an application using either the static or shared libraries. I believe as part of that we'll also find that there are still some things missing. I just ran across this PR https://github.com/nodejs/node/pull/19005 which aims to address some of those kinds of things.
At this point, I'm wondering if there is enough interest to form a group that would work together or a number of months (maybe more) on defining and validating the different embedding use cases. The work would likely be:
@yhwang @nodejs/delivery-channels @addaleax @luminosuslight, @cmfcmf, @Hannes01071995, @justus-hildebrand, @msoechting @nodejs/tsc @dshaw