File tree 2 files changed +28
-1
lines changed
2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -438,7 +438,7 @@ class Cluster extends EventEmitter {
438
438
const mapped = this . options . natMap [ key ]
439
439
if ( mapped ) {
440
440
debug ( 'NAT mapping %s -> %O' , key , mapped )
441
- return mapped
441
+ return Object . assign ( { } , mapped )
442
442
}
443
443
}
444
444
return typeof nodeKey === 'string' ? nodeKeyToRedisOptions ( nodeKey ) : nodeKey
Original file line number Diff line number Diff line change @@ -124,4 +124,31 @@ describe('NAT', () => {
124
124
125
125
cluster . get ( 'foo' )
126
126
} )
127
+
128
+ it ( 'keeps options immutable' , ( done ) => {
129
+ const slotTable = [
130
+ [ 0 , 16383 , [ '192.168.1.1' , 30001 ] ]
131
+ ]
132
+
133
+ new MockServer ( 30001 , null , slotTable )
134
+
135
+ const cluster = new Redis . Cluster ( [ {
136
+ host : '127.0.0.1' ,
137
+ port : 30001
138
+ } ] , Object . freeze ( {
139
+ natMap : Object . freeze ( {
140
+ '192.168.1.1:30001' : Object . freeze ( { host : '127.0.0.1' , port : 30001 } )
141
+ } )
142
+ } ) )
143
+
144
+ const reset = spy ( cluster . connectionPool , 'reset' )
145
+
146
+ cluster . on ( 'ready' , ( ) => {
147
+ expect ( reset . secondCall . args [ 0 ] ) . to . deep . equal ( [
148
+ { host : '127.0.0.1' , port : 30001 , readOnly : false }
149
+ ] )
150
+ cluster . disconnect ( )
151
+ done ( )
152
+ } )
153
+ } )
127
154
} )
You can’t perform that action at this time.
0 commit comments