fix(MongoClient): use mongodb-connection-string-url for host parsing (#58)#61
fix(MongoClient): use mongodb-connection-string-url for host parsing (#58)#61Botik wants to merge 1 commit intodoubleloop-io:mainfrom
Conversation
🦋 Changeset detectedLatest commit: a0e9a59 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
devmatteini
left a comment
There was a problem hiding this comment.
Hi @Botik and thank you for your contribution!
I've added some comments about the changes
| "effect-mongodb": patch | ||
| --- | ||
|
|
||
| fix(MongoClient): update tests for ConnectionString host parsing (#58) |
There was a problem hiding this comment.
This should be "Fix MongoClient.connect connection string parsing for error reporting"
| import type { DbOptions, MongoClientOptions } from "mongodb" | ||
| import type { DbOptions, MongoClientOptions, MongoParseError } from "mongodb" | ||
| import { MongoClient as MongoClient_ } from "mongodb" | ||
| import { ConnectionString } from "mongodb-connection-string-url" |
There was a problem hiding this comment.
I would avoid installing another dependency just for error reporting.
This would be a breaking change for every user of the library, which is not ideal.
I would like to find other ways to parse the connection string, maybe there is something built-in in mongodb package? Or otherwise we can also consider an empty array for hosts as you always have the cause error in the MongoError.cause
Summary
fix(MongoClient): use mongodb-connection-string-url for host parsing
new URL(url).hostwithConnectionStringfrommongodb-connection-string-urlfor proper MongoDB connection string parsingmongodb://host1:27017,host2:27017)