yfinkelstein / node-zookeeper

node.js client for Apache Zookeeper
MIT License
479 stars 111 forks source link

fix: Cannot start the zookeeper client in a Node.js Worker thread #310

Closed deepcoldy closed 2 years ago

deepcoldy commented 2 years ago

Description

replace all uv_default_loop() by Nan::GetCurrentEventLoop() here's GetCurrentEventLoop source code

Motivation and Context

Related to #281 The problem is uv_default_loop() return the main Node thread when program started, not the Worker's Event Loop in its isolated environment

How Has This Been Tested?

same as #281

Types of changes

Checklist:

DavidVujic commented 2 years ago

This is great, thank you @deepcoldy! I'll have a look and will try this out during the weekend.

DavidVujic commented 2 years ago

Starting zookeeper from a worker thread seems to work well with this change. 👏

I think it still is some work to make it work starting several instances in different worker threads, though. As an example, I still need to set the Ava test tool to not run in worker threads (in package.json).

But this change is a step in the right direction, and solves the issues described in #281

Nice job, thank you! 🚀

I will merge this one and build a new release within the next couple of days.