@@ -11,11 +11,13 @@ import { ScanCommandOptions } from '../commands/SCAN';
1111import { HScanTuple } from '../commands/HSCAN' ;
1212import { attachCommands , attachExtensions , fCallArguments , transformCommandArguments , transformCommandReply , transformLegacyCommandArguments } from '../commander' ;
1313import { Pool , Options as PoolOptions , createPool } from 'generic-pool' ;
14- import { ClientClosedError , ClientOfflineError , DisconnectsClientError } from '../errors' ;
14+ import { ClientClosedError , ClientOfflineError , DisconnectsClientError , ErrorReply } from '../errors' ;
1515import { URL } from 'url' ;
1616import { TcpSocketConnectOpts } from 'net' ;
1717import { PubSubType , PubSubListener , PubSubTypeListeners , ChannelListeners } from './pub-sub' ;
1818
19+ import { version } from '../../package.json' ;
20+
1921export interface RedisClientOptions <
2022 M extends RedisModules = RedisModules ,
2123 F extends RedisFunctions = RedisFunctions ,
@@ -66,6 +68,14 @@ export interface RedisClientOptions<
6668 * Useful with Redis deployments that do not use TCP Keep-Alive.
6769 */
6870 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 ;
6979}
7080
7181type WithCommands = {
@@ -274,6 +284,33 @@ export default class RedisClient<
274284 ) ;
275285 }
276286
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+
277314 if ( this . #options?. name ) {
278315 promises . push (
279316 this . #queue. addCommand (
0 commit comments