MongoDB and Mongoose - Create and Save a Record of a Model

Tell us what’s happening:

Hi there,

I’m facing an issue with my server after adding some code. It seems to be down without any clear reason, and I’m unsure what exactly went wrong or where the problem lies.

Could you please assist me in identifying the issue and help me get the server back up?

Thank you!

Your project link(s)

solution: Glitch :・゚✧

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36

Challenge Information:

MongoDB and Mongoose - Create and Save a Record of a Model

Do you have an account with Glitch it says the project expires after five days without one.

Hmmm, yes — I do have an account, and I’m using it for the MongoDB and backend lessons.

Ok, so what do you do first to run the project, there telling me the server is taking an unusually long time when I remix the HTML file.

Hmmm, I just normally added the code and used refresh to reconnect, and it worked before.
But now even after refreshing, the project doesn’t start.
It shows: "It looks like your project is taking an unusually long time to start up. If your project runs its own server (e.g. express, fastify, etc) please check to make sure that your code is not missing the instruction(s) to start the server."
Maybe there is some server error or something missing?

Here’s the log output:

SyntaxError: Unexpected token }
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/app/server.js:67:16)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
Terminal

Line 34 of myApp.js had what appears to be an extra curly brace and the done(null) part it connected to mongodb and mongoose. Could not find null using Node10 pops up in the terminal, not sure what that means. Hope this helps.

I found two extra code lines and fixed them. Now, the server is up and running again.
However, FreeCodeCamp still shows:

// running tests
1. Creating and saving a db item should succeed (Test timed out)
// tests completed

Why is this still happening?"

You need to submit a live URL and or your not connected to mongoose. I don’t know much about Glitch, I just started using it.

log:

😗🎫 Your app is listening on port 3000
(node:16762) UnhandledPromiseRejectionWarning: MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist: https://docs.atlas.mongodb.com/security-whitelist/
    at NativeConnection.Connection.openUri (/rbd/pnpm-volume/120ca77e-57a4-400f-8d83-a4c4c9280846/node_modules/.registry.npmjs.org/mongoose/5.13.23/node_modules/mongoose/lib/connection.js:847:32)
    at _mongoose._promiseOrCallback.cb (/rbd/pnpm-volume/120ca77e-57a4-400f-8d83-a4c4c9280846/node_modules/.registry.npmjs.org/mongoose/5.13.23/node_modules/mongoose/lib/index.js:351:10)
    at Promise (/rbd/pnpm-volume/120ca77e-57a4-400f-8d83-a4c4c9280846/node_modules/.registry.npmjs.org/mongoose/5.13.23/node_modules/mongoose/lib/helpers/promiseOrCallback.js:32:5)
    at new Promise (<anonymous>)
    at promiseOrCallback (/rbd/pnpm-volume/120ca77e-57a4-400f-8d83-a4c4c9280846/node_modules/.registry.npmjs.org/mongoose/5.13.23/node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:10)
    at Mongoose._promiseOrCallback (/rbd/pnpm-volume/120ca77e-57a4-400f-8d83-a4c4c9280846/node_modules/.registry.npmjs.org/mongoose/5.13.23/node_modules/mongoose/lib/index.js:1149:10)
    at Mongoose.connect (/rbd/pnpm-volume/120ca77e-57a4-400f-8d83-a4c4c9280846/node_modules/.registry.npmjs.org/mongoose/5.13.23/node_modules/mongoose/lib/index.js:350:20)
at Object.<anonymous> (/app/myApp.js:4:10)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/app/server.js:67:16)
(node:16762) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:16762) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
GET
MongooseError: Operation `people.insertOne()` buffering timed out after 10000ms
    at Timeout.setTimeout (/rbd/pnpm-volume/120ca77e-57a4-400f-8d83-a4c4c9280846/node_modules/.registry.npmjs.org/mongoose/5.13.23/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:198:23)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)
GET
MongooseError: Operation `people.insertOne()` buffering timed out after 10000ms
    at Timeout.setTimeout (/rbd/pnpm-volume/120ca77e-57a4-400f-8d83-a4c4c9280846/node_modules/.registry.npmjs.org/mongoose/5.13.23/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:198:23)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)

here your error, you may want to look into this

It didn’t work. I even reconnected and added my IP

maybe you need to add glitch’s ip

I’ve tried all the suggestions so far, including correcting the code, adding my current IP, and even allowing Glitch’s IP. Unfortunately, none of it has worked, and I’m still seeing the same issue. The FreeCodeCamp test still shows:

// running tests
1. Creating and saving a db item should succeed (Test timed out)
// tests completed

and what logs do you get in your app? have those changed?

🐌🌃 Your app is listening on port 3000
GET
(node:18425) UnhandledPromiseRejectionWarning: MongoError: bad auth : Authentication failed.
    at MessageStream.messageHandler (/rbd/pnpm-volume/120ca77e-57a4-400f-8d83-a4c4c9280846/node_modules/.registry.npmjs.org/mongodb/3.7.4/node_modules/mongodb/lib/cmap/connection.js:299:20)
    at MessageStream.emit (events.js:198:13)
    at processIncomingData (/rbd/pnpm-volume/120ca77e-57a4-400f-8d83-a4c4c9280846/node_modules/.registry.npmjs.org/mongodb/3.7.4/node_modules/mongodb/lib/cmap/message_stream.js:144:12)
    at MessageStream._write (/rbd/pnpm-volume/120ca77e-57a4-400f-8d83-a4c4c9280846/node_modules/.registry.npmjs.org/mongodb/3.7.4/node_modules/mongodb/lib/cmap/message_stream.js:42:5)
    at doWrite (_stream_writable.js:415:12)
    at writeOrBuffer (_stream_writable.js:399:5)
    at MessageStream.Writable.write (_stream_writable.js:299:11)
    at TLSSocket.ondata (_stream_readable.js:710:20)
    at TLSSocket.emit (events.js:198:13)
    at addChunk (_stream_readable.js:288:12)
    at readableAddChunk (_stream_readable.js:269:11)
    at TLSSocket.Readable.push (_stream_readable.js:224:10)
    at TLSWrap.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
(node:18425) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:18425) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
MongooseError: Operation `people.insertOne()` buffering timed out after 10000ms
    at Timeout.setTimeout (/rbd/pnpm-volume/120ca77e-57a4-400f-8d83-a4c4c9280846/node_modules/.registry.npmjs.org/mongoose/5.13.23/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:198:23)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)
GET
MongooseError: Operation `people.insertOne()` buffering timed out after 10000ms
    at Timeout.setTimeout (/rbd/pnpm-volume/120ca77e-57a4-400f-8d83-a4c4c9280846/node_modules/.registry.npmjs.org/mongoose/5.13.23/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:198:23)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)

that is a different error! so something changed

so now double check your authentication, it says it failed

it’s still not working. Here are the current logs for your reference:

📝🕶️ Your app is listening on port 3000
No Node version was specified; we are using default version 10. You can change this in package.json: https://help.glitch.com/hc/en-us/articles/16287495688845-Can-I-change-the-version-of-node-js-my-project-uses-
node v10.24.1, with pnpm
Installing...
Performing headless installation
Total install time: 7394ms
🔱🐙 Your app is listening on port 3000
GET
(node:18643) UnhandledPromiseRejectionWarning: MongoError: bad auth : Authentication failed.
    at MessageStream.messageHandler (/rbd/pnpm-volume/120ca77e-57a4-400f-8d83-a4c4c9280846/node_modules/.registry.npmjs.org/mongodb/3.7.4/node_modules/mongodb/lib/cmap/connection.js:299:20)
    at MessageStream.emit (events.js:198:13)
    at processIncomingData (/rbd/pnpm-volume/120ca77e-57a4-400f-8d83-a4c4c9280846/node_modules/.registry.npmjs.org/mongodb/3.7.4/node_modules/mongodb/lib/cmap/message_stream.js:144:12)
    at MessageStream._write (/rbd/pnpm-volume/120ca77e-57a4-400f-8d83-a4c4c9280846/node_modules/.registry.npmjs.org/mongodb/3.7.4/node_modules/mongodb/lib/cmap/message_stream.js:42:5)
    at doWrite (_stream_writable.js:415:12)
    at writeOrBuffer (_stream_writable.js:399:5)
    at MessageStream.Writable.write (_stream_writable.js:299:11)
    at TLSSocket.ondata (_stream_readable.js:710:20)
    at TLSSocket.emit (events.js:198:13)
    at addChunk (_stream_readable.js:288:12)
    at readableAddChunk (_stream_readable.js:269:11)
    at TLSSocket.Readable.push (_stream_readable.js:224:10)
    at TLSWrap.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
(node:18643) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:18643) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
MongooseError: Operation `people.insertOne()` buffering timed out after 10000ms
    at Timeout.setTimeout (/rbd/pnpm-volume/120ca77e-57a4-400f-8d83-a4c4c9280846/node_modules/.registry.npmjs.org/mongoose/5.13.23/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:198:23)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)
GET
Terminal

you can read this yourself, your authentication is failing

1 Like

Thank you so much for your help and patience! :folded_hands:
Everything is working now, and the issue is fully resolved.
I really appreciate your support.
Have a great day ahead!