Skip to content

Commit

Permalink
fix(WebSocketShard): dispatch race condition (#8731)
Browse files Browse the repository at this point in the history
  • Loading branch information
didinele committed Oct 10, 2022
1 parent ac83ada commit c2b6777
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/ws/src/ws/WebSocketShard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,6 @@ export class WebSocketShard extends AsyncEventEmitter<WebSocketShardEventsMap> {

switch (payload.op) {
case GatewayOpcodes.Dispatch: {
if (this.status === WebSocketShardStatus.Ready || this.status === WebSocketShardStatus.Resuming) {
this.emit(WebSocketShardEvents.Dispatch, { data: payload });
}

if (this.status === WebSocketShardStatus.Resuming) {
this.replayedEvents++;
}
Expand Down Expand Up @@ -425,6 +421,8 @@ export class WebSocketShard extends AsyncEventEmitter<WebSocketShardEventsMap> {
await this.strategy.updateSessionInfo(this.id, this.session);
}

this.emit(WebSocketShardEvents.Dispatch, { data: payload });

break;
}

Expand Down

0 comments on commit c2b6777

Please sign in to comment.