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

Support for worker_threads? #157

Closed
kylebernhardy opened this issue Dec 19, 2019 · 12 comments
Closed

Support for worker_threads? #157

kylebernhardy opened this issue Dec 19, 2019 · 12 comments

Comments

@kylebernhardy
Copy link

Does node-lmdb support worker_threads? When I attempted to implement it into a simple test wher just node-lmdn is required I got the message Error: Module did not self-register.

@kylebernhardy
Copy link
Author

Please ignore, I was implementing incorrectly. Thank you again for such a fantastic library!

@kylebernhardy
Copy link
Author

I was able to reproduce this issue. If you include node-lmdb in the parent process and in the worker thread then the error:Error: Module did not self-register. comes up. It looks like this is due to this: nodejs/node#21783 (comment)

@kylebernhardy kylebernhardy reopened this Dec 21, 2019
@Venemo
Copy link
Owner

Venemo commented Dec 22, 2019

@kylebernhardy Does the suggested fix on the link really fix the issue? If it fixes it for you then you can make a pull request of it.

@kylebernhardy
Copy link
Author

It would entail converting the project from nan to n-api & in the implementation make the module context aware. I haven't seen anywhere that nan has support for making an addon context aware, but I can look into it. Is n-api something the team for this addon has been looking into?

@Venemo
Copy link
Owner

Venemo commented Dec 22, 2019

I've been out of the loop from node development lately, since I don't use it for any new project of mine.

I had a quick glance at the docs and the context-aware thing doesn't seem to hard to do, so I believe it's worth to try it. Not sure what n-api is.

@kylebernhardy
Copy link
Author

I think I mis-read the needing to implement n-api. My C++ skills are rusty & I have not coded a native addon, but I am willing to give it a shot to implement. If you have any pointers as to where this needs to be added to the code base, please let me know. I'll keep you posted with my progress.

@Venemo
Copy link
Owner

Venemo commented Jan 15, 2020

@kylebernhardy Let me know how it goes. I'm unsure what exactly you are trying to do so I'm afraid I can't give you exact pointers about where in the code you should do it.

@d4tocchini
Copy link

kriszyp#1

@kylebernhardy, this should do the trick ;) My use-case was in electron renderers (with process reuse), I haven't tried it with worker_threads. Context-aware specific testing is most certainly needed...

@kylebernhardy
Copy link
Author

@d4tocchini , thanks! I'll check out your branch and see if it works in my use case.

@d4tocchini
Copy link

@kylebernhardy, see kriszyp#1 (comment) for caveats on worker_thread usage

@kriszyp
Copy link
Collaborator

kriszyp commented Sep 8, 2020

Support for threads/workers has been added in 0.9.4. I'd consider it beta, perhaps, but so far it seems to work properly, and I have done some decent load testing with it. Let me know if you see any issues.

@kriszyp kriszyp closed this as completed Sep 8, 2020
@kylebernhardy
Copy link
Author

@kriszyp i can create a test branch on our product and run it thru some work loads to run you work thru it’s paces. Thank you so much

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

No branches or pull requests

4 participants