Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug(database-mongo): error when using mongodb+srv protocol #629

Closed
Tracked by #615
MaikoTan opened this issue Apr 22, 2022 · 4 comments
Closed
Tracked by #615

Bug(database-mongo): error when using mongodb+srv protocol #629

MaikoTan opened this issue Apr 22, 2022 · 4 comments

Comments

@MaikoTan
Copy link
Member

Describe the bug

When setting the protocol of database-mongo plugin, it would report error that says mongodb+srv URI cannot have port number.

Steps to reproduce

  1. touch koishi.config.yml
  2. add database-mongo section with protocol set to mongodb+srv
  3. install all the stuff
  4. koishi start
  5. ERROR!

Expected behavior

Obviously be able to use the plugin normally.

Screenshots

 [W] app MongoParseError: mongodb+srv URI cannot have port number
         at new ConnectionString (/app/node_modules/mongodb-connection-string-url/lib/index.js:146:23)
         at parseOptions (/app/node_modules/mongodb/lib/connection_string.js:213:17)
         at new MongoClient (/app/node_modules/mongodb/lib/mongo_client.js:62:63)
         at Function.connect (/app/node_modules/mongodb/lib/mongo_client.js:184:33)
         at MongoDriver.start (/app/node_modules/@cosmotype/driver-mongo/lib/index.js:30:51)
         at /app/node_modules/@koishijs/plugin-database-mongo/lib/index.js:45:32
         at App.start (/app/node_modules/@koishijs/core/lib/node.js:2624:25)
         at import_core6.App.start (/app/node_modules/koishi/lib/index.js:408:16)
         at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Versions

  • OS: Ubuntu 20.04
  • Platform: Any
  • Node version: 16.18.0
  • Koishi version: 4.5.2
  • database-mongo version: 3.1.2

Additional context

No response

@MaikoTan MaikoTan added the bug BUG label Apr 22, 2022
@shigma shigma added this to the 4.7 milestone Apr 22, 2022
@MaikoTan
Copy link
Member Author

Looks like set the port as 0 would solve the problem, but I hope there is a comprehensive solution.

@shigma
Copy link
Member

shigma commented Apr 22, 2022

This is probably a regression issue. 🤣

So will checking the value of protocol and ignore port if srv is included solve the problem?

@MaikoTan
Copy link
Member Author

Are there only "mongodb+srv" protocol that requires no port in URI? If ture, I think it is ok to do the such checking.

@MaikoTan
Copy link
Member Author

Wonderful ☺️
\夢夢/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants