From ee98101e4c463910e1ca6dd099de13395cd9fa57 Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Mon, 22 Aug 2022 15:33:06 +1000 Subject: LazyRequest on mobile + socket not closed fixes --- gateway/src/opcodes/Identify.ts | 3 ++- gateway/src/opcodes/LazyRequest.ts | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'gateway/src/opcodes') diff --git a/gateway/src/opcodes/Identify.ts b/gateway/src/opcodes/Identify.ts index 041512c5..57c45d1f 100644 --- a/gateway/src/opcodes/Identify.ts +++ b/gateway/src/opcodes/Identify.ts @@ -137,12 +137,13 @@ export async function onIdentify(this: WebSocket, data: Payload) { guilds = guilds.map((guild) => { if (user.bot) { setTimeout(() => { - Send(this, { + var promise = Send(this, { op: OPCODES.Dispatch, t: EVENTEnum.GuildCreate, s: this.sequence++, d: guild, }); + if (promise) promise.catch(console.error); }, 500); return { id: guild.id, unavailable: true }; } diff --git a/gateway/src/opcodes/LazyRequest.ts b/gateway/src/opcodes/LazyRequest.ts index 0db35286..54b06eb2 100644 --- a/gateway/src/opcodes/LazyRequest.ts +++ b/gateway/src/opcodes/LazyRequest.ts @@ -39,13 +39,16 @@ async function getMembers(guild_id: string, range: [number, number]) { } catch (e) { console.error(`LazyRequest`, e); + } + + if (!members) { return { items: [], groups: [], range: [], members: [], - } - } + }; + } const groups = [] as any[]; const items = []; @@ -157,7 +160,7 @@ export async function onLazyRequest(this: WebSocket, { d }: Payload) { .flat() .unique(); - return Send(this, { + return await Send(this, { op: OPCODES.Dispatch, s: this.sequence++, t: "GUILD_MEMBER_LIST_UPDATE", -- cgit 1.5.1