Open 2chivi opened 1 month ago
Related to your issue's problem:
What version of tmi.js are you using? Node will hang if there are timers, open socket connections, etc., so can you give me minimal code that replicates this hang? Since all you said was "on tmi.Client()": no timeouts or intervals should be started before calling the connect
method.
tmi.js@v1.x
abandoned?v1.x
hasn't received an update in a while. With the v1.9.0-wip
branch, I'd like to bring necessary updates like new events, replying, removing lots of dead code, and more. You can see the changes here: main...v1.9.0-wip
.
If you'd like to try it as is, you can install the branch from GitHub using this and require/import tmi.js
as normal:
npm i tmijs/tmi.js#v1.9.0-wip
[!WARNING] Not meant for production
This does involve breaking changes but it's mostly dead features and things I wouldn't expect people to be using.
client.api
. https://github.com/tmijs/tmi.js/commit/cef6988989584c21832316a660964fdb1a4d8624action
(/me
messages) remains per Twitch. https://github.com/tmijs/tmi.js/commit/902a7369d4075ba96d3cc41b70ac15514acdb335emotesets
remains to allow for a consumer to update them with the Helix API. https://github.com/tmijs/tmi.js/commit/3edc54048dbdd4a7f03e66178946a70b4fbbd7fc??
) and optional chaining (?.
). https://github.com/tmijs/tmi.js/commit/a03ace3e76432fda658508218f4346f31fe26d35 https://github.com/tmijs/tmi.js/commit/71957147b9ca18f2e18ebe147b1ac495ba1027e6
class
syntax instead of the old style of classes. new
is required when instantiating tmi.Client
. https://github.com/tmijs/tmi.js/commit/807fa5687596025f4d61b2bb18084cc393672694EventEmitter
(a very old version of Node's EventEmitter) with a custom EventEmitter
class implementing almost the same API. https://github.com/tmijs/tmi.js/commit/f727b28d0b20c30cb111a69a0062e3e93f5de6f7
setMaxListeners
or its features. tmi.js called this.setMaxListeners(0)
in the constructor anyways so almost no one was probably using it.node-fetch
. https://github.com/tmijs/tmi.js/commit/8e4970b31da96d53fe4a6005a6c0c9d45c21d3a1^8.17.1
from 8.2.0
. https://github.com/tmijs/tmi.js/commit/cf5ab0051808074637fb6e7a662486327ee5c6a1 https://github.com/tmijs/tmi.js/commit/3e6e0968d39ac6e6f6e2304bbaf0004d5983f5d7identity.username
was removed because it's not needed to authenticate. identity.password
is still expected as either a string or a function that returns string | Promise<string>
. https://github.com/tmijs/tmi.js/commit/73127e1e396a3a7962ef65f8cd9b427937eb5c1c https://github.com/tmijs/tmi.js/commit/66c580007d61ac987bfa912043a82d81a2fded78
redeem
event. https://github.com/tmijs/tmi.js/commit/321618012926737829722b98a894094c635b0a7d
client.on('redeem', (channel: string, username: string, rewardType: string, tags: PrivmsgTags, message: string) => {
switch(rewardType) {
case 'highlighted-message':
case 'skip-subs-mode-message':
// *New* Power-ups:
case 'gigantified-emote-message': // Big emote
case 'animated-message': // Message effect
break;
default: // Like a custom reward ID or unknown, official reward type
break;
}
});
say
, action
, and reply
methods will now wait until Twitch responds. https://github.com/tmijs/tmi.js/commit/a389fc3b9b934cae9914a1f71bb00d11f1d05b34
client.say
is Promise<[ channel: string, message: string ]>
so the tags were added after for backwards compatibility. The self
value is always true
to mirror the message
event, but it might be removed before publish.'No response from Twitch.'
. I would prefer this would be an Error, but some level of backwards compatibility means I probably won't change it just yet. I feel this could easily be a justified breaking change that betters the experience with this package.
const [ _channel, _message, tags, self ] = await client.say(channel, message);
console.log('Sent message ID', tags.id);
reply
method. https://github.com/tmijs/tmi.js/commit/6b6d529214ba3efe96d1c3e4eaf0f3b8366c58d6
client.on('message', (channel, tags, message, self) => {
if(self) return;
if(message.toLowerCase() === 'hi') {
const parentMessageId = tags.id;
client.reply(channel, 'Hello', parentMessageId);
}
});
userstate
event. Emitted on joining a channel and after every message sent except for when the message is dropped (AutoMod, etc.). https://github.com/tmijs/tmi.js/commit/6f0a2b9773699d10214bed0f11bce7b5de3a03d8
/** @see https://dev.twitch.tv/docs/irc/tags/#userstate-tags */
interface UserstateTags {
'badge-info': Record<string, string>;
'badge-info-raw': string;
badges: Record<string, string>;
'badges-raw': string;
color: string;
'client-nonce': string;
'display-name': string;
'emote-sets': string;
id: string;
mod: boolean;
subscriber: boolean;
turbo: boolean;
'user-type': '' | 'admin' | 'global_mod' | 'staff';
username: string;
}
client.on('userstate', (channel: string, tags: UserstateTags) => {});
Other changes can be seen here, as linked previously.
This is an opportunity to make big changes to tmi.js.
@types/tmi.js
).reject('No response from Twitch.')
that exists in several locations).message
event for self messages to also wait for the USERSTATE
command response. This would allow for it to have the correct message ID.client-nonce
value in the message
event for self messages.client.say
return type (currently Promise<[ channel: string, message: string, tags: UserstateTags, self: true ]>
). This is only part of v1.9.0-wip
and it's not necessary to be included because it can be assumed.
Actual behaviour: Node Hangs indefinelty on tmi.Client() - Newer version of Node 21+ on Linux Ubuntu LTE
Noticed some dependencies are out of date. Could that have to do with it? Not sure if tmiV1 is abandoned? Or if we are supposed to switch to v2?
Thanks
Expected behaviour:
Error log: No errors
Configuration