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

Make module self-register (Worker threads fix) #857

Closed
wants to merge 8 commits into from

Conversation

Twixes
Copy link

@Twixes Twixes commented Dec 9, 2020

node-rdkafka was incompatible with Worker threads due to legacy context awareness, this fixes the issue for relevant versions of Node.js (>=10.7.0), retaining the old behavior for versions before that. Giving credit where its due, used guidance from nodejs/node#21783 (comment) and work already made in the node-lzo code base.
Test included.
Resolves #831.

@iradul
Copy link
Collaborator

iradul commented Jan 8, 2021

Thanks for the PR.
I've run a few local tests after merging this and I've got occasional crashes. It seems we may need to do more work on this to make the library reliably runs within worker threads.

@Twixes
Copy link
Author

Twixes commented Jan 8, 2021

Yeah, us at PostHog too. Had some awful segfaults. We've since switched to https://kafka.js.org/ and it's a much smoother experience, though probably somewhat less performant than tapping into C.

@yunnysunny
Copy link
Contributor

I have try change the addon library from Nan to node-addon-api to support Worker threads. But I'm not familiar with C++, it also have some bugs. The project link: https://github.com/node-rdkafka-next/node-rdkafka-next

@Twixes
Copy link
Author

Twixes commented Apr 5, 2021

I've switched to NAN_MODULE_WORKER_ENABLED here, which should be exactly the right (and official) macro for this. All tests green, but some stability tests need to be done here to ensure there are no crashes.

@stale
Copy link

stale bot commented Jul 21, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale Stale issues label Jul 21, 2021
@Twixes
Copy link
Author

Twixes commented Jul 21, 2021

What does this solution look like to you?

@stale stale bot removed the stale Stale issues label Jul 21, 2021
@stale
Copy link

stale bot commented Jan 8, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

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

Successfully merging this pull request may close these issues.

Module doesn't self-register from a worker thread
3 participants