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

When list children node, I add a watcher, it got error #72

Open
TruthBean opened this issue May 21, 2018 · 4 comments
Open

When list children node, I add a watcher, it got error #72

TruthBean opened this issue May 21, 2018 · 4 comments

Comments

@TruthBean
Copy link

(node:9452) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 notification listeners added. Use emitter.setMaxListeners() to increase limit;

function listChildren(path, callback) {
    client.getChildren(path, (event) => {
        logger.debug('Got watcher event: ' + event);
        if (event === Event.NODE_CHILDREN_CHANGED) {
            listChildren(path, callback);
        }
    }, (error, children, stat) => {
        let version = stat ? stat.version : 'UNKOWN';
        if (error) {
            logger.error('Failed to list children of node: ' + path + ' due to: ' + error + ' in version: ' + version);
            if (error.code === Exception.NO_NODE) callback(null);
            if (error.code === Exception.CONNECTION_LOSS) {
                client.connect();
                listChildren(path, callback);
            }
            callback([]);
        } else {
            logger.debug('Children of node: ' + path + ' in version ' + version + ' are: ' + children + ' .');
            callback(children);
        }
    });
}
@TruthBean
Copy link
Author

I got know something, every time when listChildren function is called, event will call registerChildWatcher(), so it may be a issue or not, but it should check the watcher existed before register.

@adodge1
Copy link

adodge1 commented May 26, 2020

@TruthBean did you get this figured out? I am getting the same issue.
(node:52825) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 notification listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit.
I am using client.getChildren too for zookeeper.

@davidrac
Copy link

Same for me. I'm getting a similar issue.

@sunchuanleihit
Copy link

+1

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

No branches or pull requests

4 participants