From db76d5c8fc840f8a8a689bb14466f5c5ba902bc1 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/events/Message.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'gateway/src/events/Message.ts') diff --git a/gateway/src/events/Message.ts b/gateway/src/events/Message.ts index e9271da4..1a177e0c 100644 --- a/gateway/src/events/Message.ts +++ b/gateway/src/events/Message.ts @@ -8,6 +8,8 @@ import OPCodeHandlers from "../opcodes"; import { Tuple } from "lambert-server"; import { check } from "../opcodes/instanceOf"; import WS from "ws"; +import BigIntJson from "json-bigint"; +const bigIntJson = BigIntJson({ storeAsString: true }); const PayloadSchema = { op: Number, @@ -30,16 +32,13 @@ export async function Message(this: WebSocket, buffer: WS.Data) { buffer = buffer.toString() as any; } } - data = JSON.parse(buffer as string); + data = bigIntJson.parse(buffer as string); } else if (typeof buffer == "string") { - data = JSON.parse(buffer as string); + data = bigIntJson.parse(buffer as string) } else return; - // TODO: find a way to properly convert a funny number to string - if (data?.op == 14 && typeof data.d.guild_id == "number") return; - check.call(this, PayloadSchema, data); // @ts-ignore @@ -54,7 +53,7 @@ export async function Message(this: WebSocket, buffer: WS.Data) { try { return await OPCodeHandler.call(this, data); } catch (error) { - console.error(error); + console.error(`Error: Op ${data.op}`, error); // if (!this.CLOSED && this.CLOSING) return this.close(CLOSECODES.Unknown_error); } -- cgit 1.5.1