Log more identify timings
This commit is contained in:
parent
f2427e66f0
commit
971fc4a84f
@ -92,6 +92,7 @@ export async function onIdentify(this: WebSocket, data: Payload) {
|
|||||||
});
|
});
|
||||||
if (!user) return this.close(CLOSECODES.Authentication_failed);
|
if (!user) return this.close(CLOSECODES.Authentication_failed);
|
||||||
this.user_id = user.id;
|
this.user_id = user.id;
|
||||||
|
const userQueryTime = Date.now();
|
||||||
|
|
||||||
// Check intents
|
// Check intents
|
||||||
if (!identify.intents) identify.intents = 0b11011111111111111111111111111111111n; // TODO: what is this number?
|
if (!identify.intents) identify.intents = 0b11011111111111111111111111111111111n; // TODO: what is this number?
|
||||||
@ -133,6 +134,8 @@ export async function onIdentify(this: WebSocket, data: Payload) {
|
|||||||
activities: identify.presence?.activities, // TODO: validation
|
activities: identify.presence?.activities, // TODO: validation
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const createSessionTime = Date.now();
|
||||||
|
|
||||||
// Get from database:
|
// Get from database:
|
||||||
// * the users read states
|
// * the users read states
|
||||||
// * guild members for this user
|
// * guild members for this user
|
||||||
@ -226,6 +229,8 @@ export async function onIdentify(this: WebSocket, data: Payload) {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const query1Time = Date.now();
|
||||||
|
|
||||||
// We forgot to migrate user settings from the JSON column of `users`
|
// We forgot to migrate user settings from the JSON column of `users`
|
||||||
// to the `user_settings` table theyre in now,
|
// to the `user_settings` table theyre in now,
|
||||||
// so for instances that migrated, users may not have a `user_settings` row.
|
// so for instances that migrated, users may not have a `user_settings` row.
|
||||||
@ -255,6 +260,8 @@ export async function onIdentify(this: WebSocket, data: Payload) {
|
|||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const mergedMembersTime = Date.now();
|
||||||
|
|
||||||
// Populated with guilds 'unavailable' currently
|
// Populated with guilds 'unavailable' currently
|
||||||
// Just for bots
|
// Just for bots
|
||||||
const pending_guilds: Guild[] = [];
|
const pending_guilds: Guild[] = [];
|
||||||
@ -348,6 +355,8 @@ export async function onIdentify(this: WebSocket, data: Payload) {
|
|||||||
// From user relationships ( friends ), also append to `users` list
|
// From user relationships ( friends ), also append to `users` list
|
||||||
user.relationships.forEach((x) => users.add(x.to.toPublicUser()));
|
user.relationships.forEach((x) => users.add(x.to.toPublicUser()));
|
||||||
|
|
||||||
|
const remapDataTime = Date.now();
|
||||||
|
|
||||||
// Send SESSIONS_REPLACE and PRESENCE_UPDATE
|
// Send SESSIONS_REPLACE and PRESENCE_UPDATE
|
||||||
const allSessions = (
|
const allSessions = (
|
||||||
await Session.find({
|
await Session.find({
|
||||||
@ -364,6 +373,8 @@ export async function onIdentify(this: WebSocket, data: Payload) {
|
|||||||
status: x.status,
|
status: x.status,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
const sessionReplaceTime = Date.now();
|
||||||
|
|
||||||
Promise.all([
|
Promise.all([
|
||||||
emitEvent({
|
emitEvent({
|
||||||
event: "SESSIONS_REPLACE",
|
event: "SESSIONS_REPLACE",
|
||||||
@ -457,6 +468,8 @@ export async function onIdentify(this: WebSocket, data: Payload) {
|
|||||||
d,
|
d,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const readyTime = Date.now();
|
||||||
|
|
||||||
// If we're a bot user, send GUILD_CREATE for each unavailable guild
|
// If we're a bot user, send GUILD_CREATE for each unavailable guild
|
||||||
// TODO: check if bot has permission to view some of these based on intents (i.e. GUILD_MEMBERS, GUILD_PRESENCES, GUILD_VOICE_STATES)
|
// TODO: check if bot has permission to view some of these based on intents (i.e. GUILD_MEMBERS, GUILD_PRESENCES, GUILD_VOICE_STATES)
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
@ -487,6 +500,8 @@ export async function onIdentify(this: WebSocket, data: Payload) {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const pendingGuildsTime = Date.now();
|
||||||
|
|
||||||
const readySupplementalGuilds = (
|
const readySupplementalGuilds = (
|
||||||
guilds.filter((guild) => !guild.unavailable) as Guild[]
|
guilds.filter((guild) => !guild.unavailable) as Guild[]
|
||||||
).map((guild) => {
|
).map((guild) => {
|
||||||
@ -518,12 +533,26 @@ export async function onIdentify(this: WebSocket, data: Payload) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const readySupplementalTime = Date.now();
|
||||||
|
|
||||||
//TODO send GUILD_MEMBER_LIST_UPDATE
|
//TODO send GUILD_MEMBER_LIST_UPDATE
|
||||||
//TODO send VOICE_STATE_UPDATE to let the client know if another device is already connected to a voice channel
|
//TODO send VOICE_STATE_UPDATE to let the client know if another device is already connected to a voice channel
|
||||||
|
|
||||||
await setupListener.call(this);
|
await setupListener.call(this);
|
||||||
|
|
||||||
|
const setupListenerTime = Date.now();
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
`[Gateway] IDENTIFY ${this.user_id} in ${Date.now() - startTime}ms`,
|
`[Gateway] IDENTIFY ${this.user_id} in ${Date.now() - startTime}ms`,
|
||||||
|
{
|
||||||
|
userQueryTime,
|
||||||
|
createSessionTime,
|
||||||
|
query1Time,
|
||||||
|
remapDataTime,
|
||||||
|
sessionReplaceTime,
|
||||||
|
readyTime,
|
||||||
|
pendingGuildsTime,
|
||||||
|
readySupplementalTime,
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user