feature: add event listeners to get answers from Base.send method only when explicitly asked #47
No reviewers
Labels
No Label
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: thereadme/node-telegram-api#47
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "feature/prevent-event-listener-overflow"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
In my particular use case I might be sending many messages to a contact from bot without ever expecting an answer to sent message. I've noticed that only Question class is actually dealing with
question:answer
event. Otherwise a process can end up having many event listeners stacking up in the EventEmitter's instance without being actually called as there's no response from the contact ever, thus triggering nodejs throwing an error like (this is after me increasing event listener max count):Hey!
Your argument and use case are valid, but I'd suggest we avoid breaking changes in this repository. To be honest, since the module is not actively maintained anymore, breaking changes can be much more problematic for users and for maintainers. See my comments below.
But generally, thanks for the pull-request!
This is a breaking change, I would default to
true
, and in your use case, you could avoid unnecessary listeners by setting the value to false explicitly.It might actually be the right thing to do to only listen when explicitly asked, but since this is a breaking change, I'd say we choose the safe path for now. If necessary, a major release can break this.
Is this to escape the linter? Instead I think you should avoid returning
resolve()
, but rather:Eslinter was complaining about inconsistent return point, hence needed to return something, otherwise as per your
resolve(); return;
I'll add a new commit per both your comments. Thanks!All requested changes done :)
Looks good to me, thank you!
Published as
telegram-api@4.2.0
.