LazyRequest on mobile + socket not closed fixes
This commit is contained in:
parent
d993d9c155
commit
ee98101e4c
BIN
bundle/package-lock.json
generated
BIN
bundle/package-lock.json
generated
Binary file not shown.
@ -37,12 +37,14 @@
|
||||
"@types/i18next-node-fs-backend": "^2.1.0",
|
||||
"@types/jest": "^27.0.1",
|
||||
"@types/jest-expect-message": "^1.0.3",
|
||||
"@types/json-bigint": "^1.0.1",
|
||||
"@types/jsonwebtoken": "^8.5.0",
|
||||
"@types/morgan": "^1.9.3",
|
||||
"@types/multer": "^1.4.7",
|
||||
"@types/node": "^14.18.24",
|
||||
"@types/node-fetch": "^2.5.12",
|
||||
"@types/node-os-utils": "^1.2.0",
|
||||
"@types/sharp": "^0.30.4",
|
||||
"@types/supertest": "^2.0.11",
|
||||
"@types/ws": "^7.4.0",
|
||||
"@zerollup/ts-transform-paths": "^1.7.18",
|
||||
@ -54,8 +56,7 @@
|
||||
"ts-patch": "^1.4.4",
|
||||
"tsconfig-paths": "^3.12.0",
|
||||
"typescript": "^4.2.3",
|
||||
"typescript-json-schema": "0.50.1",
|
||||
"@types/sharp": "^0.30.4"
|
||||
"typescript-json-schema": "0.50.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-s3": "^3.36.1",
|
||||
@ -81,6 +82,7 @@
|
||||
"exif-be-gone": "^1.2.0",
|
||||
"express": "^4.17.1",
|
||||
"express-async-errors": "^3.1.1",
|
||||
"fast-zlib": "^2.0.1",
|
||||
"file-type": "^16.5.4",
|
||||
"form-data": "^4.0.0",
|
||||
"fs-extra": "^10.0.0",
|
||||
@ -89,6 +91,7 @@
|
||||
"i18next-node-fs-backend": "^2.1.3",
|
||||
"image-size": "^1.0.0",
|
||||
"jest": "^27.0.6",
|
||||
"json-bigint": "^1.0.0",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
"lambert-db": "^1.2.3",
|
||||
"lambert-server": "^1.2.11",
|
||||
@ -97,6 +100,7 @@
|
||||
"multer": "^1.4.2",
|
||||
"nan": "^2.15.0",
|
||||
"nanocolors": "^0.2.12",
|
||||
"node-2fa": "^2.0.3",
|
||||
"node-fetch": "^2.6.2",
|
||||
"node-os-utils": "^1.3.5",
|
||||
"patch-package": "^6.4.7",
|
||||
@ -104,6 +108,7 @@
|
||||
"picocolors": "^1.0.0",
|
||||
"proxy-agent": "^5.0.0",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"sharp": "^0.30.7",
|
||||
"sqlite3": "^4.2.0",
|
||||
"supertest": "^6.1.6",
|
||||
"tslib": "^2.3.1",
|
||||
@ -111,8 +116,6 @@
|
||||
"typescript": "^4.1.2",
|
||||
"typescript-cached-transpile": "^0.0.6",
|
||||
"typescript-json-schema": "^0.50.1",
|
||||
"ws": "^7.4.2",
|
||||
"sharp": "^0.30.7",
|
||||
"fast-zlib": "^2.0.1"
|
||||
"ws": "^7.4.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BIN
gateway/package-lock.json
generated
BIN
gateway/package-lock.json
generated
Binary file not shown.
@ -16,6 +16,7 @@
|
||||
"license": "AGPL-3.0-only",
|
||||
"devDependencies": {
|
||||
"@types/amqplib": "^0.8.1",
|
||||
"@types/json-bigint": "^1.0.1",
|
||||
"@types/jsonwebtoken": "^8.5.0",
|
||||
"@types/node": "^14.18.24",
|
||||
"@types/node-fetch": "^2.5.12",
|
||||
@ -30,6 +31,7 @@
|
||||
"amqplib": "^0.8.0",
|
||||
"dotenv": "^8.2.0",
|
||||
"fast-zlib": "^2.0.1",
|
||||
"json-bigint": "^1.0.0",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
"lambert-server": "^1.2.11",
|
||||
"missing-native-js-functions": "^1.2.18",
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -241,7 +241,7 @@ async function consume(this: WebSocket, opts: EventOpts) {
|
||||
break;
|
||||
}
|
||||
|
||||
Send(this, {
|
||||
await Send(this, {
|
||||
op: OPCODES.Dispatch,
|
||||
t: event,
|
||||
d: data,
|
||||
|
||||
@ -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 };
|
||||
}
|
||||
|
||||
@ -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",
|
||||
|
||||
Reference in New Issue
Block a user