Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing presence updates after service restart #10721

Open
junajan opened this issue Jan 21, 2025 · 0 comments
Open

Missing presence updates after service restart #10721

junajan opened this issue Jan 21, 2025 · 0 comments

Comments

@junajan
Copy link

junajan commented Jan 21, 2025

Which package is this bug report for?

discord.js

Issue description

Hello and thank you for this project.

Using discord.js we created a bot connected to server which has over 1.2M members.
In this server we try to listen to all presence updates:

import { Client, Partials } from 'discord.js';

const bot = new Client({
  intents: 257,
  partials: [
    Partials.Channel,
    Partials.GuildMember,
    Partials.GuildScheduledEvent,
    Partials.Message,
    Partials.Reaction,
    Partials.ThreadMember,
    Partials.User,
  ],
});

bot.on('presenceUpdate', handlePresenceUpdate);

bot.on('raw', async (event: { t: string; d: any }) => {
  if (event.t === 'PRESENCE_UPDATE') {
    await handlePresenceUpdateRaw();
  }
});

@ApmMonitor('handlePresenceUpdate', 0.01) // only 1% of calls is recorded via APM
function handlePresenceUpdate() {
}

@ApmMonitor('handlePresenceUpdateRawViaDiscordJS', 0.01) // only 1% of calls is recorded via APM
function handlePresenceUpdateRaw() {
}

It looks like discord.js does not emit all presenceUpdate events at the beginning, even when all partials are turned on because when we start/restart the service, the amount of handlePresenceUpdateRawViaDiscordJS calls is much higher than handlePresenceUpdate calls.

For comparison see handlePresenceUpdateRawViaDiscordJS calls before/after restart:
Image

And handlePresenceUpdate calls during the same period:
Image

Is it possible that discord.js tries to cache some additional resource first before it emits presenceUpdate event?

Code sample

Versions

  • Node.js v20.17.0
  • discord.js 14.15.3
  • os Alpine Linux v3.20

Issue priority

Medium (should be fixed soon)

Which partials do you have configured?

User, Channel, GuildMember, Message, Reaction, GuildScheduledEvent, ThreadMember

Which gateway intents are you subscribing to?

GuildPresences

I have tested this issue on a development release

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant