fix: socket not sending message when readyState is 2 or 3

This commit is contained in:
Alexis Tyler
2021-02-22 20:01:29 +10:30
parent e2f205b032
commit 139ddd8093

View File

@@ -269,11 +269,11 @@ export class CustomSocket {
return true;
}
protected async sendMessage(clientName: string, message?: string, timeout = 1000) {
protected async sendMessage(clientName: 'relay' | 'internalGraphql', message?: string, timeout = 1000) {
const client = sockets.get(clientName)?.connection;
try {
if (!client || client.readyState === 0 || client.readyState === 2 || client.readyState === 3) {
if (!client || client.readyState === 0) {
this.logger.silly('Waiting %ss to retry sending to %s.', timeout / 1000, client?.url);
// Wait for $timeout seconds
await sleep(timeout);