Skip to content

Commit

Permalink
🚑️ fix: closing websocket requires reason
Browse files Browse the repository at this point in the history
  • Loading branch information
Helloyunho committed Nov 9, 2023
1 parent e504976 commit e3e3c73
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,9 @@ export class Client extends HarmonyEventEmitter<ClientEvents> {

/** Attempt to Close current Gateway connection and Resume */
async reconnect(): Promise<Client> {
this.gateway.closeGateway()
this.gateway.initWebsocket()
return this.waitFor('ready', () => true).then(() => this)
await this.gateway.reconnect()
await this.waitFor('resumed')
return this
}

/** Add a new Collector */
Expand Down
4 changes: 2 additions & 2 deletions src/gateway/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ export class Gateway extends HarmonyEventEmitter<GatewayTypedEvents> {
await this.cache.delete(`seq_${this.shards?.join('-') ?? '0'}`)
}

this.closeGateway(3999)
this.closeGateway(RECONNECT_CODE, 'Reconnecting...')
this.initWebsocket()
}

Expand Down Expand Up @@ -494,7 +494,7 @@ export class Gateway extends HarmonyEventEmitter<GatewayTypedEvents> {
reason !== undefined && reason !== '' ? ` and reason ${reason}` : ''
}`
)
return this.websocket?.close(code, reason)
this.websocket?.close(code, reason)
}

// Alias for backward compat, since [email protected] removed close again...
Expand Down

0 comments on commit e3e3c73

Please sign in to comment.