Skip to content

Commit

Permalink
fix(WebSocketManager): always cache result of fetchGatewayInformation (
Browse files Browse the repository at this point in the history
…#9611)

* fix(WebSocketManager): always cache result of fetchGatewayInformation

* fix: add comment
  • Loading branch information
Qjuh authored May 29, 2023
1 parent 24a6149 commit df8b6e9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/ws/src/ws/WebSocketManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ export class WebSocketManager extends AsyncEventEmitter<ManagerShardEventsMap> {

const data = (await this.options.rest.get(Routes.gatewayBot())) as RESTGetAPIGatewayBotResult;

this.gatewayInformation = { data, expiresAt: Date.now() + data.session_start_limit.reset_after };
// For single sharded bots session_start_limit.reset_after will be 0, use 5 seconds as a minimum expiration time
this.gatewayInformation = { data, expiresAt: Date.now() + (data.session_start_limit.reset_after || 5_000) };
return this.gatewayInformation.data;
}

Expand Down

0 comments on commit df8b6e9

Please sign in to comment.