In MongoClient.ts:22, when catching connection errors, the code attempts to parse the URL using new URL(url) to extract the hostname for the error message. However, this fails for valid MongoDB connection strings that contain multiple comma-separated hosts, such as:
mongodb://host1.example.com:27018,host2.example.com:27018,host3.example.com:27018/mydb
This URL format is valid for MongoDB clients but throws a TypeError when passed to the standard URL constructor because the comma-separated hosts are not a valid URL path component.
In MongoClient.ts:22, when catching connection errors, the code attempts to parse the URL using
new URL(url)to extract the hostname for the error message. However, this fails for valid MongoDB connection strings that contain multiple comma-separated hosts, such as:This URL format is valid for MongoDB clients but throws a TypeError when passed to the standard URL constructor because the comma-separated hosts are not a valid URL path component.