mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 04:23:31 +01:00
fix(WebSocketShard): #send race condition due to ready state (#9226)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -383,14 +383,9 @@ export class WebSocketShard extends AsyncEventEmitter<WebSocketShardEventsMap> {
|
|||||||
d,
|
d,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { ok } = await this.bubbleWaitForEventError(
|
await this.bubbleWaitForEventError(
|
||||||
this.waitForEvent(WebSocketShardEvents.Ready, this.strategy.options.readyTimeout),
|
this.waitForEvent(WebSocketShardEvents.Ready, this.strategy.options.readyTimeout),
|
||||||
);
|
);
|
||||||
if (!ok) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.#status = WebSocketShardStatus.Ready;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async resume(session: SessionInfo) {
|
private async resume(session: SessionInfo) {
|
||||||
@@ -499,7 +494,7 @@ export class WebSocketShard extends AsyncEventEmitter<WebSocketShardEventsMap> {
|
|||||||
// eslint-disable-next-line sonarjs/no-nested-switch
|
// eslint-disable-next-line sonarjs/no-nested-switch
|
||||||
switch (payload.t) {
|
switch (payload.t) {
|
||||||
case GatewayDispatchEvents.Ready: {
|
case GatewayDispatchEvents.Ready: {
|
||||||
this.emit(WebSocketShardEvents.Ready, { data: payload.d });
|
this.#status = WebSocketShardStatus.Ready;
|
||||||
|
|
||||||
this.session ??= {
|
this.session ??= {
|
||||||
sequence: payload.s,
|
sequence: payload.s,
|
||||||
@@ -510,6 +505,8 @@ export class WebSocketShard extends AsyncEventEmitter<WebSocketShardEventsMap> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
await this.strategy.updateSessionInfo(this.id, this.session);
|
await this.strategy.updateSessionInfo(this.id, this.session);
|
||||||
|
|
||||||
|
this.emit(WebSocketShardEvents.Ready, { data: payload.d });
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user