-
Notifications
You must be signed in to change notification settings - Fork 58
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
Cannot create multiple NodeJSEnvironment for one NodeJSPlatform #348
Comments
I can reproduce this. While destroying one environment and then creating another will work, creating a second concurrent environment crashes. @vmoroz It should be supported, right? Can you try adding a test case for this in the libnode PR? |
@camnewnham , I am currently working on the new version of the The issue should be addressed in the new version of the API. The plan is adopt it in the node-api-dotnet project as soon as we complete the key outstanding TODOs. I.e. maybe even before the PR is merged. This is to be sure sure that the new API can be integrated well with .Net. |
@camnewnham , I am also looking for real life scenarios for the |
The specific scenario I have for multiple environments is:
Currently each node is in a shared environment. The current behaviour is:
The problem being that (2) interferes with other nodes which may have independent timeouts (related: #355) or cached data. Ideally, the environment would be unique to the node and editing one would be isolated from any other. |
Thank you, @camnewnham , for sharing your scenario!
|
Yes, that's correct. They will reasonably frequently be created and disposed.
I don't have a strong preference here, but expectations based on the current |
Running each Node.js environment in its own thread is generally fine.
We must be able to mix and match different modes. I was just wondering if your case fits into these categories, and so far it seems that it must be covered. Another aspect is that there can be only a single debuggable Node.js root environment per process. |
@camnewnham Could you use multiple worker threads in one environment, instead of multiple environments? I recently added support for using worker threads from C#. That's available in version 0.8.13 or later. |
Possibly. The initial cause I had for reloading environments is because I needed to re-import the same (updated) JS file/function. I've only used workers minimally in JS - so I'd need to learn a little more about imports/context and limitations. Are methods on the dotnet host accessible from the JS workers? |
The docs suggest that multiple environments can exist concurrently for the sample platform.
I get an assertion failure from this simple console application:
libnode was built with the instructions and is using the suggested
napi-libnode-v20.9.0
branch.The text was updated successfully, but these errors were encountered: