mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-08-02 16:08:31 +00:00
4.59.1
* Fixed: Remove debug logging. * Experiment Changed: Tweak the MQTT pub/sub client to handle subscription failures better.
This commit is contained in:
parent
a7e131070e
commit
5046088bf7
4 changed files with 27 additions and 6 deletions
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "frankerfacez",
|
"name": "frankerfacez",
|
||||||
"author": "Dan Salvato LLC",
|
"author": "Dan Salvato LLC",
|
||||||
"version": "4.59.0",
|
"version": "4.59.1",
|
||||||
"description": "FrankerFaceZ is a Twitch enhancement suite.",
|
"description": "FrankerFaceZ is a Twitch enhancement suite.",
|
||||||
"private": true,
|
"private": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
|
|
|
@ -140,6 +140,7 @@ export default class PubSub extends Module {
|
||||||
const PubSubClient = await this.loadPubSubClient();
|
const PubSubClient = await this.loadPubSubClient();
|
||||||
|
|
||||||
const client = this._client = new PubSubClient(cluster, {
|
const client = this._client = new PubSubClient(cluster, {
|
||||||
|
logger: this.log.get('client'),
|
||||||
user: user?.id ? {
|
user: user?.id ? {
|
||||||
provider: 'twitch',
|
provider: 'twitch',
|
||||||
id: user.id
|
id: user.id
|
||||||
|
|
|
@ -281,8 +281,8 @@ export class EventEmitter {
|
||||||
if ( ret instanceof Promise ) {
|
if ( ret instanceof Promise ) {
|
||||||
if ( (args[0] instanceof FFZWaitableEvent) )
|
if ( (args[0] instanceof FFZWaitableEvent) )
|
||||||
args[0].waitFor(ret);
|
args[0].waitFor(ret);
|
||||||
else if ( this.log )
|
/*else if ( this.log )
|
||||||
this.log.error(`handler for event "${event}" returned a Promise but the event is not an FFZWaitableEvent`);
|
this.log.debug(`handler for event "${event}" returned a Promise but the event is not an FFZWaitableEvent`);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (args[0] instanceof FFZEvent && args[0].propagationStopped) || ret === StopPropagation )
|
if ( (args[0] instanceof FFZEvent && args[0].propagationStopped) || ret === StopPropagation )
|
||||||
|
|
|
@ -590,14 +590,34 @@ export default class PubSubClient extends EventEmitter {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
|
|
||||||
return this._client.subscribe({topicFilter: topics })
|
return this._client.subscribe({topicFilter: topics })
|
||||||
.catch(() => {
|
.then(() => {
|
||||||
|
// Success. Reset the subscribe failures count.
|
||||||
|
this._sub_failures = 0;
|
||||||
|
})
|
||||||
|
.catch(msg => {
|
||||||
|
// TODO: Check the reason why.
|
||||||
|
if ( this.logger )
|
||||||
|
this.logger.debug('Subscribe failure for topics:', batch.join(', '), ' reason:', msg);
|
||||||
|
|
||||||
// If there was an error, we did NOT subscribe.
|
// If there was an error, we did NOT subscribe.
|
||||||
for(const topic of batch)
|
for(const topic of batch)
|
||||||
this._live_topics.delete(topic);
|
this._live_topics.delete(topic);
|
||||||
|
|
||||||
|
// See if we have more work.
|
||||||
|
if ( this._live_topics.size >= this._active_topics.size )
|
||||||
|
return;
|
||||||
|
|
||||||
// Call sendSubscribes again after a bit.
|
// Call sendSubscribes again after a bit.
|
||||||
if ( this._live_topics.size != this._active_topics.size )
|
this._sub_failures = (this._sub_failures || 0) + 1;
|
||||||
return sleep(2000).then(() => this._sendSubscribes());
|
|
||||||
|
let delay = (this._sub_failures * Math.floor(Math.random() * 10) + 2) * 1000;
|
||||||
|
if ( delay > 60000 )
|
||||||
|
delay = (Math.floor(Math.random() * 60) + 30) * 1000;
|
||||||
|
|
||||||
|
if ( delay <= 2000 )
|
||||||
|
delay = 2000;
|
||||||
|
|
||||||
|
return sleep(delay).then(() => this._sendSubscribes());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue