File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ import {
4040 uuid ,
4141} from '.' ;
4242import Redis from './redis' ;
43+ import { logger } from '../test/mocks' ;
4344
4445const RX_CLIENT_NAME = / n a m e = ( \S + ) / g;
4546const RX_CLIENT_TEST = / : ( r e a d e r | w r i t e r | w a t c h e r ) / ;
@@ -807,7 +808,10 @@ export class RedisQueue extends EventEmitter<EventMap>
807808 autoResendUnfulfilledCommands : true ,
808809 } ) ;
809810
810- context [ channel ] = makeRedisSafe ( redis ) ;
811+ context [ channel ] = makeRedisSafe (
812+ redis ,
813+ options . verbose ? options . logger : undefined ,
814+ ) ;
811815 context [ channel ] . __imq = true ;
812816
813817 for ( const event of [
Original file line number Diff line number Diff line change 2323 */
2424/* tslint:disable */
2525import Redis from 'ioredis' ;
26+ import { ILogger } from './IMessageQueue' ;
2627
2728/**
2829 * Extends default Redis type to allow dynamic properties access on it
@@ -35,7 +36,10 @@ export interface IRedisClient extends Redis {
3536}
3637
3738// istanbul ignore next
38- export function makeRedisSafe ( redis : IRedisClient ) : IRedisClient {
39+ export function makeRedisSafe (
40+ redis : IRedisClient ,
41+ logger ?: ILogger ,
42+ ) : IRedisClient {
3943 return new Proxy ( redis , {
4044 get ( target , property , receiver ) {
4145 const original = Reflect . get ( target , property , receiver ) ;
@@ -44,11 +48,18 @@ export function makeRedisSafe(redis: IRedisClient): IRedisClient {
4448 return async ( ...args : unknown [ ] ) => {
4549 try {
4650 if ( target . status !== 'ready' ) {
51+ logger ?. warn (
52+ 'Redis client is not ready yet, while ' ,
53+ `executing command: "${ String ( property ) } "` ,
54+ ) ;
55+
4756 return null ;
4857 }
4958
5059 return await original . apply ( target , args ) ;
5160 } catch ( err : unknown ) {
61+ logger ?. error ( err ) ;
62+
5263 return null ;
5364 }
5465 } ;
You can’t perform that action at this time.
0 commit comments