Skip to content

Commit 23415ee

Browse files
authored
Merge branch 'master' into an-widget
2 parents 174d61f + 60d22ee commit 23415ee

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## Version 25.03.XX
22
Fixes:
33
- [core] Fix user analytics widget chart
4+
- [core] Fix mongo connection url parsing
45

56
## Version 25.03.10
67
Enterprise Fixes:

plugins/pluginManager.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ var pluginDependencies = require('./pluginDependencies.js'),
1111
apiCountlyConfig = require('../api/config', 'dont-enclose'),
1212
utils = require('../api/utils/utils.js'),
1313
fs = require('fs'),
14-
url = require('url'),
1514
querystring = require('querystring'),
1615
cp = require('child_process'),
1716
async = require("async"),
@@ -1877,9 +1876,21 @@ var pluginManager = function pluginManager() {
18771876
}
18781877

18791878
if (config && typeof config.mongodb === "string") {
1880-
var urlParts = url.parse(config.mongodb, true);
1881-
if (urlParts && urlParts.query && urlParts.query.maxPoolSize) {
1882-
maxPoolSize = urlParts.query.maxPoolSize;
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('?');
1888+
1889+
if (urlParts.length > 1) {
1890+
const queryParams = new URLSearchParams(urlParts[1]);
1891+
1892+
maxPoolSize = queryParams.get('maxPoolSize') !== null ? queryParams.get('maxPoolSize') : maxPoolSize;
1893+
}
18831894
}
18841895
}
18851896
else {

0 commit comments

Comments
 (0)