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
## 2.0.3
## 2.0.4
### Major Changes

View File

@ -25,7 +25,7 @@ import type { DiscordUser } from '@biscuitland/api-types';
## Example for [Deno](https://deno.land/)
```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

View File

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

View File

@ -5,7 +5,7 @@ export const BASE_URL = 'https://discord.com/api';
export const API_VERSION = 10;
/** 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 */
export const USER_AGENT = `DiscordBot (https://github.com/oasisjs/biscuit, v${BISCUIT_VERSION})`;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -65,7 +65,6 @@ export class DefaultWsAdapter implements WsAdapter {
},
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);
},
});

View File

@ -319,28 +319,7 @@ export class Shard {
const jitter = Math.ceil(this.heart.interval * (Math.random() || 0.5));
const it1: any = setTimeout(() => {
this.socket?.send(
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;
if (this.state === ShardState.Connected) {
this.socket?.send(
JSON.stringify({
op: GatewayOpcodes.Heartbeat,
@ -349,11 +328,36 @@ export class Shard {
);
this.heart.lastBeat = Date.now();
this.heart.acknowledged = false;
this.events.heartbeat?.(this);
}, this.heart.interval);
const it: any = setInterval(async () => {
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);
this.heart.timeoutId = it1;
@ -395,13 +399,15 @@ export class Shard {
this.heart.lastBeat = Date.now();
this.socket?.send(
JSON.stringify({
op: GatewayOpcodes.Heartbeat,
d: this.options.previousSequenceNumber,
}),
);
this.events.heartbeat?.(this);
if (this.state === ShardState.Connected) {
this.socket?.send(
JSON.stringify({
op: GatewayOpcodes.Heartbeat,
d: this.options.previousSequenceNumber,
}),
);
this.events.heartbeat?.(this);
}
break;
}