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

Set Hexo's EventEmitter.MaxListeners to 100 #5504

Open
2 tasks done
kristofzerbe opened this issue Jun 24, 2024 · 5 comments
Open
2 tasks done

Set Hexo's EventEmitter.MaxListeners to 100 #5504

kristofzerbe opened this issue Jun 24, 2024 · 5 comments

Comments

@kristofzerbe
Copy link
Contributor

Check List

  • I have already read Docs page.
  • I have already searched existing issues.

Feature Request

I make heavy use of hexo.on("ready") and got now following NodeJS warning:

(node:16804) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 ready listeners added to [Hexo]. MaxListeners is 10. Use emitter.setMaxListeners() to increase limit

I set manually this.setMaxListeners(100); in constructor of hexo/index.js of Hexo class to avoid the problem, but it would be better to extend this in code base.

Others

No response

@SukkaW
Copy link
Member

SukkaW commented Jun 26, 2024

IMHO it is not common to add 11 listeners on one event. 10 looks like a sane default setting to me and I don't see any reason to increase that in Hexo.

@kristofzerbe
Copy link
Contributor Author

Ok ... therefore the use of hexo.on("ready") and other events is limited in Hexo to 10, if you want to avoid those warnings. Correct? If yes, this limitation should be documented under hexo.io API

@SukkaW
Copy link
Member

SukkaW commented Jun 26, 2024

Ok ... therefore the use of hexo.on("ready") and other events is limited in Hexo to 10, if you want to avoid those warnings. Correct? If yes, this limitation should be documented under hexo.io API

This limitation comes from Node.js, not from Hexo.

@kristofzerbe
Copy link
Contributor Author

You are right. It is a Node topic, but Hexo runs under node and has to deal with it. Maybe it could be an option to introduce a config item for this?

@SukkaW
Copy link
Member

SukkaW commented Jun 28, 2024

You are right. It is a Node topic, but Hexo runs under node and has to deal with it.

As I said, it is very rare to add 11 listeners on one event. In fact, in the 12 years of Hexo's history, you are the first one to see this warning.

https://github.com/hexojs/hexo/issues?q=is%3Aissue+is%3Aopen+Possible+EventEmitter+memory+leak+detected

And since you already have access to setMaxListeners, so why an extra option anyway?

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

2 participants