Skip to content
This repository has been archived by the owner on Jul 15, 2024. It is now read-only.

Commit

Permalink
fix: only reset invalidated once
Browse files Browse the repository at this point in the history
  • Loading branch information
KagChi committed Jan 3, 2023
1 parent 3f1e7b4 commit ffca848
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nezuchan/nezu-gateway",
"version": "1.2.3",
"version": "1.2.4",
"description": "A standalone service for connecting to the Discord gateway.",
"main": "dist",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/Listeners/Sockets/SocketDebugListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class SocketDebugListener extends Listener {
await collection.set(`${payload.shardId}`, { ping, shardId: payload.shardId });
}

if (payload.shardId === 0 && payload.message.includes("Invalid session; will attempt to resume: false")) {
if (this.container.gateway.resetInvalidatedOnStart && payload.shardId === 0 && payload.message.includes("Invalid session; will attempt to resume: false")) {
await new RedisCollection({ redis: this.container.gateway.redis, hash: process.env.USE_ROUTING === "true" ? `${this.container.gateway.clientId}:${Constants.GUILD_KEY}` : Constants.GUILD_KEY }).clear();
await new RedisCollection({ redis: this.container.gateway.redis, hash: process.env.USE_ROUTING === "true" ? `${this.container.gateway.clientId}:${Constants.CHANNEL_KEY}` : Constants.CHANNEL_KEY }).clear();
await new RedisCollection({ redis: this.container.gateway.redis, hash: process.env.USE_ROUTING === "true" ? `${this.container.gateway.clientId}:${Constants.MESSAGE_KEY}` : Constants.MESSAGE_KEY }).clear();
Expand Down
2 changes: 1 addition & 1 deletion src/Listeners/Sockets/SocketReadyListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ import { WebSocketShardEvents } from "@discordjs/ws";

export class SocketReadyListener extends Listener {
public run(payload: { shardId: number }): void {
this.container.gateway.logger.info(`Shard ${payload.shardId} ready`);
this.container.gateway.logger.info(`Shard ${payload.shardId} ready`); this.container.gateway.resetInvalidatedOnStart = false;
}
}
1 change: 1 addition & 0 deletions src/Structures/NezuGateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class NezuGateway extends EventEmitter {

public clientId = Buffer.from(process.env.DISCORD_TOKEN!.split(".")[0], "base64").toString();
public stores = new StoreRegistry();
public resetInvalidatedOnStart = true;

public prometheus = new APM({
PORT: process.env.PROMETHEUS_PORT ?? 9090,
Expand Down

0 comments on commit ffca848

Please sign in to comment.