tested with +150.000 guilds | ETIMEDOUT readyState finished

This commit is contained in:
Dragurimu 2022-08-20 07:39:07 -05:00
parent b8c29ae2ad
commit b4c94bc1a8
16 changed files with 68 additions and 63 deletions

View File

@ -1,6 +1,6 @@
# @biscuitland/api-types # @biscuitland/api-types
## 2.0.3 ## 2.0.4
### Major Changes ### Major Changes

View File

@ -25,7 +25,7 @@ import type { DiscordUser } from '@biscuitland/api-types';
## Example for [Deno](https://deno.land/) ## Example for [Deno](https://deno.land/)
```ts ```ts
import type { DiscordUser } from "https://unpkg.com/@biscuitland/api-types@2.0.3/dist/index.d.ts"; import type { DiscordUser } from "https://unpkg.com/@biscuitland/api-types@2.0.4/dist/index.d.ts";
``` ```
We deliver this package through [unpkg](https://unpkg.com/) and it does contain constants and routes too We deliver this package through [unpkg](https://unpkg.com/) and it does contain constants and routes too

View File

@ -1,6 +1,6 @@
{ {
"name": "@biscuitland/api-types", "name": "@biscuitland/api-types",
"version": "2.0.3", "version": "2.0.4",
"main": "./dist/index.js", "main": "./dist/index.js",
"module": "./dist/index.mjs", "module": "./dist/index.mjs",
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",

View File

@ -5,7 +5,7 @@ export const BASE_URL = 'https://discord.com/api';
export const API_VERSION = 10; export const API_VERSION = 10;
/** https://github.com/oasisjs/biscuit/releases */ /** https://github.com/oasisjs/biscuit/releases */
export const BISCUIT_VERSION = '2.0.3'; export const BISCUIT_VERSION = '2.0.4';
/** https://discord.com/developers/docs/reference#user-agent */ /** https://discord.com/developers/docs/reference#user-agent */
export const USER_AGENT = `DiscordBot (https://github.com/oasisjs/biscuit, v${BISCUIT_VERSION})`; export const USER_AGENT = `DiscordBot (https://github.com/oasisjs/biscuit, v${BISCUIT_VERSION})`;

View File

@ -1,6 +1,6 @@
# @biscuitland/cache # @biscuitland/cache
## 2.0.3 ## 2.0.4
### Major Changes ### Major Changes
@ -9,4 +9,4 @@
### Patch Changes ### Patch Changes
- Updated dependencies - Updated dependencies
- @biscuitland/api-types@2.0.3 - @biscuitland/api-types@2.0.4

View File

@ -1,6 +1,6 @@
{ {
"name": "@biscuitland/cache", "name": "@biscuitland/cache",
"version": "2.0.3", "version": "2.0.4",
"main": "./dist/index.js", "main": "./dist/index.js",
"module": "./dist/index.mjs", "module": "./dist/index.mjs",
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",
@ -23,7 +23,7 @@
} }
}, },
"dependencies": { "dependencies": {
"@biscuitland/api-types": "^2.0.3", "@biscuitland/api-types": "^2.0.4",
"ioredis": "^5.2.2" "ioredis": "^5.2.2"
}, },
"devDependencies": { "devDependencies": {

View File

@ -1,6 +1,6 @@
# @biscuitland/core # @biscuitland/core
## 2.0.3 ## 2.0.4
### Major Changes ### Major Changes
@ -9,6 +9,6 @@
### Patch Changes ### Patch Changes
- Updated dependencies - Updated dependencies
- @biscuitland/api-types@2.0.3 - @biscuitland/api-types@2.0.4
- @biscuitland/rest@2.0.3 - @biscuitland/rest@2.0.4
- @biscuitland/ws@2.0.3 - @biscuitland/ws@2.0.4

View File

@ -1,6 +1,6 @@
{ {
"name": "@biscuitland/core", "name": "@biscuitland/core",
"version": "2.0.3", "version": "2.0.4",
"main": "./dist/index.js", "main": "./dist/index.js",
"module": "./dist/index.mjs", "module": "./dist/index.mjs",
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",
@ -23,9 +23,9 @@
} }
}, },
"dependencies": { "dependencies": {
"@biscuitland/api-types": "^2.0.3", "@biscuitland/api-types": "^2.0.4",
"@biscuitland/rest": "^2.0.3", "@biscuitland/rest": "^2.0.4",
"@biscuitland/ws": "^2.0.3" "@biscuitland/ws": "^2.0.4"
}, },
"devDependencies": { "devDependencies": {
"tsup": "^6.1.3" "tsup": "^6.1.3"

View File

@ -1,9 +1,9 @@
# @biscuitland/helpers # @biscuitland/helpers
## 2.0.3 ## 2.0.4
### Patch Changes ### Patch Changes
- Updated dependencies - Updated dependencies
- @biscuitland/api-types@2.0.3 - @biscuitland/api-types@2.0.4
- @biscuitland/core@2.0.3 - @biscuitland/core@2.0.4

View File

@ -1,6 +1,6 @@
{ {
"name": "@biscuitland/helpers", "name": "@biscuitland/helpers",
"version": "2.0.3", "version": "2.0.4",
"main": "./dist/index.js", "main": "./dist/index.js",
"module": "./dist/index.mjs", "module": "./dist/index.mjs",
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",
@ -23,8 +23,8 @@
} }
}, },
"dependencies": { "dependencies": {
"@biscuitland/api-types": "^2.0.3", "@biscuitland/api-types": "^2.0.4",
"@biscuitland/core": "^2.0.3" "@biscuitland/core": "^2.0.4"
}, },
"devDependencies": { "devDependencies": {
"tsup": "^6.1.3" "tsup": "^6.1.3"

View File

@ -1,6 +1,6 @@
# @biscuitland/rest # @biscuitland/rest
## 2.0.3 ## 2.0.4
### Major Changes ### Major Changes
@ -9,4 +9,4 @@
### Patch Changes ### Patch Changes
- Updated dependencies - Updated dependencies
- @biscuitland/api-types@2.0.3 - @biscuitland/api-types@2.0.4

View File

@ -1,6 +1,6 @@
{ {
"name": "@biscuitland/rest", "name": "@biscuitland/rest",
"version": "2.0.3", "version": "2.0.4",
"main": "./dist/index.js", "main": "./dist/index.js",
"module": "./dist/index.mjs", "module": "./dist/index.mjs",
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",
@ -23,7 +23,7 @@
} }
}, },
"dependencies": { "dependencies": {
"@biscuitland/api-types": "^2.0.3" "@biscuitland/api-types": "^2.0.4"
}, },
"devDependencies": { "devDependencies": {
"tsup": "^6.1.3" "tsup": "^6.1.3"

View File

@ -1,6 +1,6 @@
# @biscuitland/ws # @biscuitland/ws
## 2.0.3 ## 2.0.4
### Major Changes ### Major Changes
@ -9,4 +9,4 @@
### Patch Changes ### Patch Changes
- Updated dependencies - Updated dependencies
- @biscuitland/api-types@2.0.3 - @biscuitland/api-types@2.0.4

View File

@ -1,6 +1,6 @@
{ {
"name": "@biscuitland/ws", "name": "@biscuitland/ws",
"version": "2.0.3", "version": "2.0.4",
"main": "./dist/index.js", "main": "./dist/index.js",
"module": "./dist/index.mjs", "module": "./dist/index.mjs",
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",
@ -23,7 +23,7 @@
} }
}, },
"dependencies": { "dependencies": {
"@biscuitland/api-types": "^2.0.3", "@biscuitland/api-types": "^2.0.4",
"ws": "^8.8.1" "ws": "^8.8.1"
}, },
"devDependencies": { "devDependencies": {

View File

@ -65,7 +65,6 @@ export class DefaultWsAdapter implements WsAdapter {
}, },
handleIdentify: (id: number) => { handleIdentify: (id: number) => {
// console.log(id % this.options.gatewayBot.sessionStartLimit.maxConcurrency, id, this.options.gatewayBot.sessionStartLimit.maxConcurrency);
return this.buckets.get(id % this.options.gatewayBot.sessionStartLimit.maxConcurrency)!.leak.acquire(1); return this.buckets.get(id % this.options.gatewayBot.sessionStartLimit.maxConcurrency)!.leak.acquire(1);
}, },
}); });

View File

@ -319,28 +319,7 @@ export class Shard {
const jitter = Math.ceil(this.heart.interval * (Math.random() || 0.5)); const jitter = Math.ceil(this.heart.interval * (Math.random() || 0.5));
const it1: any = setTimeout(() => { const it1: any = setTimeout(() => {
this.socket?.send( if (this.state === ShardState.Connected) {
JSON.stringify({
op: GatewayOpcodes.Heartbeat,
d: this.options.previousSequenceNumber,
})
);
this.heart.lastBeat = Date.now();
this.heart.acknowledged = false;
const it: any = setInterval(async () => {
if (!this.heart.acknowledged) {
this.close(
ShardSocketCloseCodes.ZombiedConnection,
'Zombied connection, did not receive an heartbeat ACK in time.'
);
return await this.identify();
}
this.heart.acknowledged = false;
this.socket?.send( this.socket?.send(
JSON.stringify({ JSON.stringify({
op: GatewayOpcodes.Heartbeat, op: GatewayOpcodes.Heartbeat,
@ -349,11 +328,36 @@ export class Shard {
); );
this.heart.lastBeat = Date.now(); this.heart.lastBeat = Date.now();
this.heart.acknowledged = false;
this.events.heartbeat?.(this); const it: any = setInterval(async () => {
}, this.heart.interval); if (!this.heart.acknowledged) {
this.close(
ShardSocketCloseCodes.ZombiedConnection,
'Zombied connection, did not receive an heartbeat ACK in time.'
);
this.heart.intervalId = it; return await this.identify();
}
this.heart.acknowledged = false;
if (this.state === ShardState.Connected) {
this.socket?.send(
JSON.stringify({
op: GatewayOpcodes.Heartbeat,
d: this.options.previousSequenceNumber,
})
);
this.heart.lastBeat = Date.now();
this.events.heartbeat?.(this);
}
}, this.heart.interval);
this.heart.intervalId = it;
}
}, jitter); }, jitter);
this.heart.timeoutId = it1; this.heart.timeoutId = it1;
@ -395,13 +399,15 @@ export class Shard {
this.heart.lastBeat = Date.now(); this.heart.lastBeat = Date.now();
this.socket?.send( if (this.state === ShardState.Connected) {
JSON.stringify({ this.socket?.send(
op: GatewayOpcodes.Heartbeat, JSON.stringify({
d: this.options.previousSequenceNumber, op: GatewayOpcodes.Heartbeat,
}), d: this.options.previousSequenceNumber,
); }),
this.events.heartbeat?.(this); );
this.events.heartbeat?.(this);
}
break; break;
} }