@@ -11,11 +11,13 @@ import { ScanCommandOptions } from '../commands/SCAN';
11
11
import { HScanTuple } from '../commands/HSCAN' ;
12
12
import { attachCommands , attachExtensions , fCallArguments , transformCommandArguments , transformCommandReply , transformLegacyCommandArguments } from '../commander' ;
13
13
import { Pool , Options as PoolOptions , createPool } from 'generic-pool' ;
14
- import { ClientClosedError , ClientOfflineError , DisconnectsClientError } from '../errors' ;
14
+ import { ClientClosedError , ClientOfflineError , DisconnectsClientError , ErrorReply } from '../errors' ;
15
15
import { URL } from 'url' ;
16
16
import { TcpSocketConnectOpts } from 'net' ;
17
17
import { PubSubType , PubSubListener , PubSubTypeListeners , ChannelListeners } from './pub-sub' ;
18
18
19
+ import { version } from '../../package.json' ;
20
+
19
21
export interface RedisClientOptions <
20
22
M extends RedisModules = RedisModules ,
21
23
F extends RedisFunctions = RedisFunctions ,
@@ -66,6 +68,14 @@ export interface RedisClientOptions<
66
68
* Useful with Redis deployments that do not use TCP Keep-Alive.
67
69
*/
68
70
pingInterval ?: number ;
71
+ /**
72
+ * If set to true, disables sending client identifier (user-agent like message) to the redis server
73
+ */
74
+ disableClientInfo ?: boolean ;
75
+ /**
76
+ * Tag to append to library name that is sent to the Redis server
77
+ */
78
+ clientInfoTag ?: string ;
69
79
}
70
80
71
81
type WithCommands = {
@@ -274,6 +284,33 @@ export default class RedisClient<
274
284
) ;
275
285
}
276
286
287
+ if ( ! this . #options?. disableClientInfo ) {
288
+ promises . push (
289
+ this . #queue. addCommand (
290
+ [ 'CLIENT' , 'SETINFO' , 'LIB-VER' , version ] ,
291
+ { asap : true }
292
+ ) . catch ( err => {
293
+ if ( ! ( err instanceof ErrorReply ) ) {
294
+ throw err ;
295
+ }
296
+ } )
297
+ ) ;
298
+
299
+ promises . push (
300
+ this . #queue. addCommand (
301
+ [
302
+ 'CLIENT' , 'SETINFO' , 'LIB-NAME' ,
303
+ this . #options?. clientInfoTag ? `node-redis(${ this . #options. clientInfoTag } )` : 'node-redis'
304
+ ] ,
305
+ { asap : true }
306
+ ) . catch ( err => {
307
+ if ( ! ( err instanceof ErrorReply ) ) {
308
+ throw err ;
309
+ }
310
+ } )
311
+ ) ;
312
+ }
313
+
277
314
if ( this . #options?. name ) {
278
315
promises . push (
279
316
this . #queue. addCommand (
0 commit comments