Gelbpunkt / gateway-proxy

Drop-in proxy for Discord gateway connections and sessions allowing for zero downtime deploys
GNU Affero General Public License v3.0
88 stars 17 forks source link

Possibility some caches not sent correctly to clients #27

Closed KagChi closed 5 months ago

KagChi commented 5 months ago

I've been encountered error while integrating this with DiscordJS, managed to get it work just a few minor issue which is

nezu  | 2024-06-28T09:13:06.214762066Z [2024-06-28 09:13:06.170 +0000] ERROR (20): Encountered error on event listener "CorePreMessageParser" for event "preMessageParsed" at path "::virtual::"
nezu  | 2024-06-28T09:13:06.214822427Z     err: {
nezu  | 2024-06-28T09:13:06.214830787Z       "type": "TypeError",
nezu  | 2024-06-28T09:13:06.214835387Z       "message": "Cannot read properties of undefined (reading 'id')",
nezu  | 2024-06-28T09:13:06.214839547Z       "stack":
nezu  | 2024-06-28T09:13:06.214842987Z           TypeError: Cannot read properties of undefined (reading 'id')
nezu  | 2024-06-28T09:13:06.214846747Z               at get cache [as cache] (/app/node_modules/.pnpm/discord.js@14.15.3/node_modules/discord.js/src/managers/GuildMemberRoleManager.js:37:101)
nezu  | 2024-06-28T09:13:06.214851027Z               at TextChannel.memberPermissions (/app/node_modules/.pnpm/discord.js@14.15.3/node_modules/discord.js/src/structures/GuildChannel.js:221:32)
nezu  | 2024-06-28T09:13:06.214855547Z               at TextChannel.permissionsFor (/app/node_modules/.pnpm/discord.js@14.15.3/node_modules/discord.js/src/structures/GuildChannel.js:177:29)
nezu  | 2024-06-28T09:13:06.214859947Z               at _CoreListener.canRunInChannel (file:///app/node_modules/.pnpm/@sapphire+framework@5.2.1/node_modules/@sapphire/framework/dist/esm/optional-listeners/message-command-listeners/CorePreMessageParser.mjs:46:36)
nezu  | 2024-06-28T09:13:06.214865307Z               at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
nezu  | 2024-06-28T09:13:06.214869107Z               at async _CoreListener.run (file:///app/node_modules/.pnpm/@sapphire+framework@5.2.1/node_modules/@sapphire/framework/dist/esm/optional-listeners/message-command-listeners/CorePreMessageParser.mjs:13:20)
nezu  | 2024-06-28T09:13:06.214873707Z               at async Object.fromAsync (file:///app/node_modules/.pnpm/@sapphire+result@2.6.6/node_modules/@sapphire/result/dist/esm/index.mjs:617:22)

Some of DJS maintainers said everyone role was not cached.

Here is the configuration i used for gateway-proxy

{
    "log_level": "info",
    "token": "REDACTED",
    "intents": 641,
    "port": 7878,
    "activity": {
      "type": 2,
      "name": "/play(っ^▿^)"
    },
    "status": "online",
    "backpressure": 100,
    "validate_token": true,
    "externally_accessible_url": "REDACTED",
    "cache": {
      "channels": true,
      "presences": false,
      "emojis": false,
      "current_member": true,
      "members": false,
      "roles": true,
      "scheduled_events": false,
      "stage_instances": false,
      "stickers": false,
      "users": true,
      "voice_states": true
    }
}

And here is the cache customization on DJS

            sweepers: {
                guildMembers: {
                    interval: 3_600,
                    filter: () => member => member.id !== member.client.user.id
                }
            },

            partials: [Partials.Message, Partials.Channel],
            makeCache: manager => {
                if (["VoiceStateManager", "GuildManager", "GuildChannelManager", "ChannelManager", "RoleManager", "PermissionOverwriteManager", "GuildMemberManager"].includes(manager.name)) return new Collection();
                return new LimitedCollection({ maxSize: 0 });
            },
Gelbpunkt commented 5 months ago

I need payload logs, your bot's logs aren't very helpful here.

KagChi commented 5 months ago

Do any race conditions possible here? i have checked staging bot payloads, they seems to be good

KagChi commented 5 months ago

also, what are backpressure used for?