twurple: ERROR Disconnected unexpectedly: Connection already present
Bug Report
I have had this happen every now and then (randomly) on a chatbot I have running and can’t really explain it. My app crashes: ircv3 ERROR Disconnected unexpectedly: [1006] and the reason seems to be: Error: Connection already present which doesn’t make a lot of sense to me.
Expected behavior
I guess this should just be handled since a connection is still there, because currently it crashes my app. But maybe I need to specifically catch this somehow?
Actual Behavior
It seems at random:
2021-01-19T23:41:00: [2021-01-19T23:41:00.182Z] ❌ ircv3 ERROR Disconnected unexpectedly: [1006]
2021-01-19T23:41:01: Error: Connection already present
2021-01-19T23:41:01: at PersistentConnection.<anonymous> (file:///app/node_modules/@d-fischer/connection/es/PersistentConnection.mjs:74:35)
2021-01-19T23:41:01: at step (/app/node_modules/tslib/tslib.js:140:27)
2021-01-19T23:41:01: at Object.next (/app/node_modules/tslib/tslib.js:121:57)
2021-01-19T23:41:01: at /app/node_modules/tslib/tslib.js:114:75
2021-01-19T23:41:01: at new Promise (<anonymous>)
2021-01-19T23:41:01: at __awaiter (/app/node_modules/tslib/tslib.js:110:16)
2021-01-19T23:41:01: at PersistentConnection.connect (file:///app/node_modules/@d-fischer/connection/es/PersistentConnection.mjs:67:16)
2021-01-19T23:41:01: at ChatClient.<anonymous> (file:///app/node_modules/ircv3/es/IrcClient.mjs:381:63)
2021-01-19T23:41:01: at step (/app/node_modules/tslib/tslib.js:140:27)
2021-01-19T23:41:01: at Object.next (/app/node_modules/tslib/tslib.js:121:57)
Code
There seems to be a specific reason why this error is thrown but I fail to understand it so I don’t really know how to fix this:
// node_modules/@d-fischer/connection/es/PersistentConnection.mjs
...
if (this._currentConnection || this._connecting) {
throw new Error('Connection already present');
}
...
Environment
- Version: v4.3.6
- Node version: v14.15.4
- Operating system: CentOS Linux 7 (Core)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 35 (12 by maintainers)
@FransTwisk @roncli
I have just pushed a small update for the
@d-fischer/connectionlibrary (version 6.4.2).Please update only that package to try the fix. (Removing it from your lockfile, then running
yarnornpm installagain, should do the trick the easiest)This update should prevent the “Connection already present” error.
Please report back with your experience with the update.
If the error goes away with this, I will publish a new patch version of the
twitchlibraries soon with a hard dependency on this new patch. (It might actually fix other connection stability problems as well!)