Comments (6)
This is because you've added duplicate event handlers. Event handlers are not removed on disconnect.
from tmi.js.
You will eventually get this error message "(node) warning: possible EventEmitter memory leak detected. [...]" because that code will keep adding a new listener for the same message event every time "reconnect" is called.
async function reconnect() { await client.disconnect(); await client.connect(); client.on('message', messageHandler); } await reconnect(); // client._events.message is a function await reconnect(); // client._events.message is now an array console.log(client._events.message.length); // 2 await reconnect(); console.log(client._events.message.length); // 3 await reconnect(); console.log(client._events.message.length); // 4Instead it should look more like this:
client.on('message', messageHandler); async function reconnect() { await client.disconnect(); await client.connect(); }
Thanks you for your response. I've tried in this way y seems to work:
// Desconectamos
await this.tmiClient.disconnect();
// Liberamos los triggers
this.tmiClient.removeAllListeners();
What do you think, is it good alternative for prevent duplication?
from tmi.js.
I think you're better off just moving when/where you add the listeners instead of removing all of them just to re-add them unnecessarily.
from tmi.js.
You will eventually get this error message "(node) warning: possible EventEmitter memory leak detected. [...]" because that code will keep adding a new listener for the same message event every time "reconnect" is called.
async function reconnect() {
await client.disconnect();
await client.connect();
client.on('message', messageHandler);
}
await reconnect();
// client._events.message is a function
await reconnect();
// client._events.message is now an array
console.log(client._events.message.length); // 2
await reconnect();
console.log(client._events.message.length); // 3
await reconnect();
console.log(client._events.message.length); // 4
Instead it should look more like this:
client.on('message', messageHandler);
async function reconnect() {
await client.disconnect();
await client.connect();
}
from tmi.js.
Okey. Thank you very much!
from tmi.js.
This works for me! Thanks @samyan!!!
this.tmiClient.removeAllListeners();
from tmi.js.
Related Issues (20)
- Emoticons dont work anymroe for long time. Fix it please? HOT 1
- My account was BANNED because of tmi js HOT 1
- add Hype Train event and channel point event PLEASEEE HOT 1
- Can't connect to server with OAuth token authorization HOT 2
- Wrong message ID for messages sent from client HOT 4
- Cannot read properties of undefined (reading 'startsWith') in Commands.js of tmi.js HOT 1
- Type errors
- Create and get poll results HOT 1
- Client auto-joins channels after reconnect
- help
- client.on('redeem', ....) doesn't listen for reward redemption without viewer message HOT 1
- How do we get the sub tier? HOT 5
- Did number of subs get removed from giftsub?
- Properties with type T | undefined can be null
- Missing userstate in type definitions of ban and timeout events HOT 1
- Unrecognized command: /ban HOT 7
- In `client.on('redeem',......` , Is there a way to obtain the message was sent in that reward? HOT 1
- Missing Component HOT 1
- periodic error log HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tmi.js.