Skip to content

Commit 70debc7

Browse files
committed
minor fixes
1 parent 52b7b24 commit 70debc7

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

src/RedisQueue.ts

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,10 @@ export class RedisQueue extends EventEmitter<EventMap>
438438
await this.start();
439439
}
440440

441+
if (!this.writer) {
442+
throw new TypeError('IMQ: unable to initialize queue!');
443+
}
444+
441445
const id = uuid();
442446
const data: IMessage = { id, message, from: this.name };
443447
const key = `${this.options.prefix}:${toQueue}`;
@@ -856,7 +860,9 @@ export class RedisQueue extends EventEmitter<EventMap>
856860
this.emit('message', message, id, from);
857861
} catch (err) {
858862
// istanbul ignore next
859-
this.emitError('OnMessage', 'process error - message is invalid',
863+
this.emitError(
864+
'OnMessage',
865+
'process error - message is invalid',
860866
err,
861867
);
862868
}
@@ -879,12 +885,9 @@ export class RedisQueue extends EventEmitter<EventMap>
879885
const rx = new RegExp(
880886
`\\bname=${this.options.prefix}:[\\S]+?:watcher:`,
881887
);
882-
const list = await this.writer.client('LIST') as string;
888+
const list = <string>await this.writer.client('LIST');
883889

884-
return (list || '')
885-
.split(/\r?\n/)
886-
.filter(client => rx.test(client))
887-
.length;
890+
return list.split(/\r?\n/).filter(client => rx.test(client)).length;
888891
}
889892

890893
/**
@@ -903,8 +906,11 @@ export class RedisQueue extends EventEmitter<EventMap>
903906
);
904907
}
905908
} catch (err) {
906-
this.emitError('OnProcessDelayed', 'error processing delayed queue',
907-
err);
909+
this.emitError(
910+
'OnProcessDelayed',
911+
'error processing delayed queue',
912+
err,
913+
);
908914
}
909915
}
910916

@@ -939,8 +945,11 @@ export class RedisQueue extends EventEmitter<EventMap>
939945
return;
940946
}
941947
} catch (err) {
942-
this.emitError('OnSafeDelivery',
943-
'safe queue message delivery problem', err);
948+
this.emitError(
949+
'OnSafeDelivery',
950+
'safe queue message delivery problem',
951+
err,
952+
);
944953
this.cleanSafeCheckInterval();
945954

946955
return;
@@ -1194,10 +1203,12 @@ export class RedisQueue extends EventEmitter<EventMap>
11941203
const msgArr: any = await this.writer.lrange(
11951204
workerKey, -1, 1,
11961205
);
1206+
11971207
if (msgArr.length !== 1) {
11981208
// noinspection ExceptionCaughtLocallyJS
11991209
throw new Error('Wrong messages count');
12001210
}
1211+
12011212
const msg = msgArr[0];
12021213

12031214
this.process([key, msg]);

src/UDPClusterManager.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
* purchase a proprietary commercial license. Please contact us at
2222
* <[email protected]> to get commercial licensing options.
2323
*/
24-
import {
25-
IMessageQueueConnection,
26-
} from './IMessageQueue';
24+
import { IMessageQueueConnection } from './IMessageQueue';
2725
import { ICluster, ClusterManager } from './ClusterManager';
2826
import { Socket, createSocket } from 'dgram';
2927
import { networkInterfaces } from 'os';

0 commit comments

Comments
 (0)