File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -101,21 +101,19 @@ const VALID_MODES = [
101101 * @return {ReadPreference }
102102 */
103103ReadPreference . fromOptions = function ( options ) {
104+ if ( ! options ) return null ;
104105 const readPreference = options . readPreference ;
106+ if ( ! readPreference ) return null ;
105107 const readPreferenceTags = options . readPreferenceTags ;
106-
107- if ( readPreference == null ) {
108- return null ;
109- }
110-
108+ const maxStalenessSeconds = options . maxStalenessSeconds ;
111109 if ( typeof readPreference === 'string' ) {
112110 return new ReadPreference ( readPreference , readPreferenceTags ) ;
113111 } else if ( ! ( readPreference instanceof ReadPreference ) && typeof readPreference === 'object' ) {
114112 const mode = readPreference . mode || readPreference . preference ;
115113 if ( mode && typeof mode === 'string' ) {
116114 return new ReadPreference ( mode , readPreference . tags , {
117- maxStalenessSeconds : readPreference . maxStalenessSeconds ,
118- hedge : options . hedge
115+ maxStalenessSeconds : readPreference . maxStalenessSeconds || maxStalenessSeconds ,
116+ hedge : readPreference . hedge
119117 } ) ;
120118 }
121119 }
You can’t perform that action at this time.
0 commit comments