This repository was archived by the owner on Feb 4, 2022. It is now read-only.
File tree 1 file changed +15
-8
lines changed
1 file changed +15
-8
lines changed Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
- const Binary = require ( 'mongodb-core' ) . BSON . Binary ,
3
+ const ReadPreference = require ( './topologies/read_preference' ) ,
4
+ Binary = require ( 'mongodb-core' ) . BSON . Binary ,
4
5
uuidV4 = require ( './utils' ) . uuidV4 ;
5
6
6
7
/**
@@ -40,16 +41,22 @@ class ClientSession {
40
41
// can be sent to any mongos. When connected to a replica set the
41
42
// endSessions command MUST be sent to the primary if the primary
42
43
// is available, otherwise it MUST be sent to any available secondary.
44
+ // Is it enough to use: ReadPreference.primaryPreferred ?
43
45
44
- this . topology . command ( 'admin.$cmd' , { endSessions : 1 , ids : [ this . id ] } , err => {
45
- this . hasEnded = true ;
46
+ this . topology . command (
47
+ 'admin.$cmd' ,
48
+ { endSessions : 1 , ids : [ this . id ] } ,
49
+ { readPreference : ReadPreference . primaryPreferred } ,
50
+ err => {
51
+ this . hasEnded = true ;
46
52
47
- // release the server session back to the pool
48
- this . sessionPool . release ( this . serverSession ) ;
53
+ // release the server session back to the pool
54
+ this . sessionPool . release ( this . serverSession ) ;
49
55
50
- if ( err ) return callback ( err , null ) ;
51
- callback ( null , null ) ;
52
- } ) ;
56
+ if ( err ) return callback ( err , null ) ;
57
+ callback ( null , null ) ;
58
+ }
59
+ ) ;
53
60
}
54
61
}
55
62
You can’t perform that action at this time.
0 commit comments