File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -1876,12 +1876,21 @@ var pluginManager = function pluginManager() {
18761876 }
18771877
18781878 if ( config && typeof config . mongodb === "string" ) {
1879- const urlParts = config . mongodb . split ( '?' ) ;
1879+ try {
1880+ const urlObj = new URL ( config . mongodb ) ;
1881+ // mongo connection string with multiple host like 'mongodb://localhost:30000,localhost:30001' will cause an error
1882+
1883+ maxPoolSize = urlObj . searchParams . get ( 'maxPoolSize' ) !== null ? urlObj . searchParams . get ( 'maxPoolSize' ) : maxPoolSize ;
1884+ }
1885+ catch ( _err ) {
1886+ // we catch the error here and try to process only the query params part
1887+ const urlParts = config . mongodb . split ( '?' ) ;
18801888
1881- if ( urlParts . length > 1 ) {
1882- const queryParams = new URLSearchParams ( urlParts [ 1 ] ) ;
1889+ if ( urlParts . length > 1 ) {
1890+ const queryParams = new URLSearchParams ( urlParts [ 1 ] ) ;
18831891
1884- maxPoolSize = queryParams . get ( 'maxPoolSize' ) || maxPoolSize ;
1892+ maxPoolSize = queryParams . get ( 'maxPoolSize' ) !== null ? queryParams . get ( 'maxPoolSize' ) : maxPoolSize ;
1893+ }
18851894 }
18861895 }
18871896 else {
You can’t perform that action at this time.
0 commit comments