Skip to content

Commit

Permalink
Merge branch 'main' into tm-fix-redis4-multi-crash
Browse files Browse the repository at this point in the history
  • Loading branch information
pichlermarc authored Oct 13, 2023
2 parents 3a7c993 + 247a81c commit 5000091
Showing 1 changed file with 23 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,23 +166,31 @@ export class RedisInstrumentation extends InstrumentationBase<any> {
this._diag.debug('Patching redis client');
const redisClientPrototype = moduleExports?.default?.prototype;

if (isWrapped(redisClientPrototype?.multi)) {
this._unwrap(redisClientPrototype, 'multi');
// In some @redis/client versions 'multi' is a method. In later
// versions, as of https://github.com/redis/node-redis/pull/2324,
// 'MULTI' is a method and 'multi' is a property defined in the
// constructor that points to 'MULTI', and therefore it will not
// be defined on the prototype.
if (redisClientPrototype?.multi) {
if (isWrapped(redisClientPrototype?.multi)) {
this._unwrap(redisClientPrototype, 'multi');
}
this._wrap(
redisClientPrototype,
'multi',
this._getPatchRedisClientMulti()
);
}
this._wrap(
redisClientPrototype,
'multi',
this._getPatchRedisClientMulti()
);

if (isWrapped(redisClientPrototype?.MULTI)) {
this._unwrap(redisClientPrototype, 'MULTI');
if (redisClientPrototype?.MULTI) {
if (isWrapped(redisClientPrototype?.MULTI)) {
this._unwrap(redisClientPrototype, 'MULTI');
}
this._wrap(
redisClientPrototype,
'MULTI',
this._getPatchRedisClientMulti()
);
}
this._wrap(
redisClientPrototype,
'MULTI',
this._getPatchRedisClientMulti()
);

if (isWrapped(redisClientPrototype?.sendCommand)) {
this._unwrap(redisClientPrototype, 'sendCommand');
Expand Down

0 comments on commit 5000091

Please sign in to comment.