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

Mongo error on startup #15186

Open
ploissken opened this issue Apr 18, 2024 · 4 comments
Open

Mongo error on startup #15186

ploissken opened this issue Apr 18, 2024 · 4 comments

Comments

@ploissken
Copy link

General Info

  • UUID: 9ae7f3de-9061-4f4b-829c-586dd7dcc12a
  • Browser: Chrome
  • OS: macOS Ventura

Description

I was following instructions here for starting the server on localhost.
I never had mongo installed here before. Running npm run mongo:dev resulted in an error:

> [email protected] mongo:dev
> run-rs -v 5.0.23 -h -l ubuntu1804 --keep --dbpath mongodb-data --number 1 --quiet

Skipping purge
Running '/Users/rs-producepay/Documents/habitica/node_modules/run-rs/5.0.23/mongod' [ 27017 ]
Restarting replica set...
Error: Server is unavailable
    at /Users/rs-producepay/Documents/habitica/node_modules/mongodb-topology-manager/lib/utils.js:79:40
    at Socket.<anonymous> (/Users/rs-producepay/Documents/habitica/node_modules/mongodb-topology-manager/lib/utils.js:43:5)
    at Socket.emit (node:events:513:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

I went googling around and found a workaround.
Posting it here to raise awareness about the issue and also in case anyone runs into it.

  1. I've started changing the mongo:dev script in packages.json. I've added -h 127.0.0.1 to it, following a hint from this thread. The updated line in package.json now looks like this:

"mongo:dev": "run-rs -v 5.0.23 -h 127.0.0.1 -l ubuntu1804 --keep --dbpath mongodb-data --number 1 --quiet",

  1. Then I deleted all the files in /mongodb-data
  2. When I run the npm run mongo:dev again, the error is gone:
> [email protected] mongo:dev
> run-rs -v 5.0.23 -h 127.0.0.1 -l ubuntu1804 --keep --dbpath mongodb-data --number 1 --quiet

Skipping purge
Running '/Users/bodurico/Documents/habitica/node_modules/run-rs/5.0.23/mongod' [ 27017 ]
Restarting replica set...
Started replica set on "mongodb://127.0.0.1:27017?replicaSet=rs"
  1. Then I hardcoded the mongo url above into the function getDevelopmentConnectionUrl in website/server/libs/mongodb.js. (Pretty nasty sorry)
return "mongodb://127.0.0.1:27017?replicaSet=rs";
  1. npm run start went fine and no more troubles after that
> [email protected] start
> gulp nodemon

[17:24:10] Using gulpfile ~/Documents/habitica/gulpfile.js
[17:24:10] Starting 'nodemon'...
[17:24:10] Finished 'nodemon' after 13 ms
[17:24:10] [nodemon] 2.0.22
[17:24:10] [nodemon] to restart at any time, enter `rs`
[17:24:10] [nodemon] watching path(s): *.*
[17:24:10] [nodemon] watching extensions: js,mjs,json
[17:24:10] [nodemon] starting `node ./website/server/index.js`
2024-04-18T20:24:12.339Z - info Express server listening on port 3000
2024-04-18T20:24:12.347Z - info Connected with Mongoose.

I'll try to research deeper into this for a proper solution. Any hints would be appreciate!

@CuriousMagpie
Copy link
Member

@SabreCat Can you take a look at this? Thanks!

@diyoyo
Copy link

diyoyo commented Apr 30, 2024

@ploissken Never tried the regular install of Habitica (I want to make it work using docker), but I found out that the mongoose version 7.6.3 is messing things up when using mongo5 (again, this is my observation for docker containers)

I would suggest switching mongoose to 5.13.22 in package.json

@diyoyo
Copy link

diyoyo commented Apr 30, 2024

@ploissken also, the Wiki (fandom) page seems outdated since Habitica 5.22 is supposed to run on Node20/Npm10.

@CuriousMagpie
Copy link
Member

@diyoyo you are correct--we are running Node 20 and MongoDB 5.0.23 now. I'd recommend that @ploissken run npm ci to get a clean install of all the dependencies and try again--making changes to package.json and getDevelopmentConnectionUrl shouldn't be necessary!

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

3 participants