mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-04 01:40:08 +00:00
remove cleanup shard logic
This commit is contained in:
@@ -174,8 +174,6 @@ export const ws = {
|
||||
log,
|
||||
/** Handles resharding the bot when necessary. */
|
||||
resharder,
|
||||
/** Cleanups loading shards that were unable to load. */
|
||||
cleanupLoadingShards,
|
||||
};
|
||||
|
||||
export interface DiscordenoShard {
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
import { ws } from "./ws.ts";
|
||||
|
||||
/** The handler to clean up shards that identified but never received a READY. */
|
||||
export function cleanupLoadingShards() {
|
||||
if (!ws.loadingShards.size) return;
|
||||
|
||||
ws.log("DEBUG", "Running setTimeout in cleanupLoadingShards function.");
|
||||
const now = Date.now();
|
||||
ws.loadingShards.forEach((loadingShard) => {
|
||||
ws.log("DEBUG", `Running forEach loop in cleanupLoadingShards function.`);
|
||||
// Not a minute yet. Max should be few seconds but do a minute to be safe.
|
||||
if (now < loadingShard.startedAt + 60000) return;
|
||||
|
||||
loadingShard.reject(
|
||||
`[Identify Failure] Shard ${loadingShard.shardId} has not received READY event in over a minute.`
|
||||
);
|
||||
});
|
||||
|
||||
if (ws.loadingShards.size) setTimeout(cleanupLoadingShards, 10000);
|
||||
}
|
||||
@@ -54,10 +54,13 @@ export function identify(shardId: number, maxShards: number) {
|
||||
ws.loadingShards.set(shardId, {
|
||||
shardId,
|
||||
resolve,
|
||||
reject,
|
||||
startedAt: Date.now(),
|
||||
});
|
||||
|
||||
ws.cleanupLoadingShards();
|
||||
setTimeout(() => {
|
||||
reject(
|
||||
`[Identify Failure] Shard ${shardId} has not received READY event in over a minute.`
|
||||
);
|
||||
}, 600000);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { DiscordGatewayOpcodes } from "../types/codes/gateway_opcodes.ts";
|
||||
import { Collection } from "../util/collection.ts";
|
||||
import { cleanupLoadingShards } from "./cleanup_loading_shards.ts";
|
||||
import { closeWS } from "./close_ws.ts";
|
||||
import { createShard } from "./create_shard.ts";
|
||||
import { log } from "./events.ts";
|
||||
@@ -78,7 +77,6 @@ export const ws = {
|
||||
{
|
||||
shardId: number;
|
||||
resolve: (value: unknown) => void;
|
||||
reject: (reason?: unknown) => void;
|
||||
startedAt: number;
|
||||
}
|
||||
>(),
|
||||
@@ -112,8 +110,6 @@ export const ws = {
|
||||
log,
|
||||
/** Handles resharding the bot when necessary. */
|
||||
resharder,
|
||||
/** Cleanups loading shards that were unable to load. */
|
||||
cleanupLoadingShards,
|
||||
/** Handles the message events from websocket. */
|
||||
handleOnMessage,
|
||||
/** Handles processing queue of requests send to this shard. */
|
||||
|
||||
Reference in New Issue
Block a user