mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
Increase WebSocket backoff time to alleviate reconnect issues
This commit is contained in:
@@ -69,6 +69,8 @@ class WebSocketManager extends EventEmitter {
|
||||
|
||||
this.lastHeartbeatAck = true;
|
||||
|
||||
this._remainingReset = 0;
|
||||
|
||||
this._trace = [];
|
||||
this.resumeStart = -1;
|
||||
}
|
||||
@@ -100,7 +102,7 @@ class WebSocketManager extends EventEmitter {
|
||||
this._connect(gateway);
|
||||
this.first = false;
|
||||
} else {
|
||||
this.client.setTimeout(() => this._connect(gateway), 5500);
|
||||
this.client.setTimeout(() => this._connect(gateway), 7500);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,7 +153,7 @@ class WebSocketManager extends EventEmitter {
|
||||
const item = this._queue[0];
|
||||
if (!(this.ws.readyState === WebSocketConnection.WebSocket.OPEN && item)) return;
|
||||
if (this.remaining === 0) {
|
||||
this.client.setTimeout(this.doQueue.bind(this), Date.now() - this.remainingReset);
|
||||
this.client.setTimeout(this.doQueue.bind(this), Date.now() + (this._remainingReset || 120e3));
|
||||
return;
|
||||
}
|
||||
this._remaining--;
|
||||
|
||||
@@ -99,10 +99,10 @@ class ShardingManager extends EventEmitter {
|
||||
/**
|
||||
* Spawns multiple shards.
|
||||
* @param {number} [amount=this.totalShards] Number of shards to spawn
|
||||
* @param {number} [delay=5500] How long to wait in between spawning each shard (in milliseconds)
|
||||
* @param {number} [delay=7500] How long to wait in between spawning each shard (in milliseconds)
|
||||
* @returns {Promise<Collection<number, Shard>>}
|
||||
*/
|
||||
spawn(amount = this.totalShards, delay = 5500) {
|
||||
spawn(amount = this.totalShards, delay = 7500) {
|
||||
if (amount === 'auto') {
|
||||
return Util.fetchRecommendedShards(this.token).then(count => {
|
||||
this.totalShards = count;
|
||||
|
||||
Reference in New Issue
Block a user