@@ -13,10 +13,10 @@ const cloneOptions = require('./shared').cloneOptions;
13
13
const SessionMixins = require ( './shared' ) . SessionMixins ;
14
14
const isRetryableWritesSupported = require ( './shared' ) . isRetryableWritesSupported ;
15
15
const relayEvents = require ( '../utils' ) . relayEvents ;
16
- const isRetryableError = require ( '../error' ) . isRetryableError ;
17
16
const BSON = retrieveBSON ( ) ;
18
17
const getMMAPError = require ( './shared' ) . getMMAPError ;
19
18
const makeClientMetadata = require ( '../utils' ) . makeClientMetadata ;
19
+ const legacyIsRetryableWriteError = require ( './shared' ) . legacyIsRetryableWriteError ;
20
20
21
21
/**
22
22
* @fileOverview The **Mongos** class is a class that represents a Mongos Proxy topology and is
@@ -113,6 +113,18 @@ var Mongos = function(seedlist, options) {
113
113
// Get replSet Id
114
114
this . id = id ++ ;
115
115
116
+ // deduplicate seedlist
117
+ if ( Array . isArray ( seedlist ) ) {
118
+ seedlist = seedlist . reduce ( ( seeds , seed ) => {
119
+ if ( seeds . find ( s => s . host === seed . host && s . port === seed . port ) ) {
120
+ return seeds ;
121
+ }
122
+
123
+ seeds . push ( seed ) ;
124
+ return seeds ;
125
+ } , [ ] ) ;
126
+ }
127
+
116
128
// Internal state
117
129
this . s = {
118
130
options : Object . assign ( { metadata : makeClientMetadata ( options ) } , options ) ,
@@ -911,7 +923,7 @@ function executeWriteOperation(args, options, callback) {
911
923
912
924
const handler = ( err , result ) => {
913
925
if ( ! err ) return callback ( null , result ) ;
914
- if ( ! isRetryableError ( err ) || ! willRetryWrite ) {
926
+ if ( ! legacyIsRetryableWriteError ( err , self ) || ! willRetryWrite ) {
915
927
err = getMMAPError ( err ) ;
916
928
return callback ( err ) ;
917
929
}
@@ -1107,7 +1119,7 @@ Mongos.prototype.command = function(ns, cmd, options, callback) {
1107
1119
1108
1120
const cb = ( err , result ) => {
1109
1121
if ( ! err ) return callback ( null , result ) ;
1110
- if ( ! isRetryableError ( err ) ) {
1122
+ if ( ! legacyIsRetryableWriteError ( err , self ) ) {
1111
1123
return callback ( err ) ;
1112
1124
}
1113
1125
@@ -1121,8 +1133,8 @@ Mongos.prototype.command = function(ns, cmd, options, callback) {
1121
1133
1122
1134
// increment and assign txnNumber
1123
1135
if ( willRetryWrite ) {
1124
- options . session . incrementTransactionNumber ( ) ;
1125
- options . willRetryWrite = willRetryWrite ;
1136
+ clonedOptions . session . incrementTransactionNumber ( ) ;
1137
+ clonedOptions . willRetryWrite = willRetryWrite ;
1126
1138
}
1127
1139
1128
1140
// Execute the command
0 commit comments