MongoDB and Mongoose - test timed out

Tell us what’s happening:
For MongoDB and Mongoose - Create and Save a Record of a Model
Everytime I submit the reply page, the tests on the freecodecamp page say ‘test timed out’.
My bash terminal is showing that there’s a get request.

It looks like there was a thread with similar issues before causing them to move from Glitch to, but I’m still having troubles with this error.

The terminal is also throwing this error everytime.

Your app is listening on port 3000
(node:2211) UnhandledPromiseRejectionWarning: TypeError: Cannot read property ‘split’ of null
at parseSrvConnectionString (/home/runner/url/node_modules/mongodb/lib/core/uri_parser.js:44:23)
at parseConnectionString (/home/runner/url/node_modules/mongodb/lib/core/uri_parser.js:587:12)
at connect (/home/runner/url/node_modules/mongodb/lib/operations/connect.js:282:3)
at /home/runner/url/node_modules/mongodb/lib/mongo_client.js:223:5
at maybePromise (/home/runner/url/node_modules/mongodb/lib/utils.js:662:3)
at MongoClient.connect (/home/runner/url/node_modules/mongodb/lib/mongo_client.js:219:10)
at /home/runner/url/node_modules/mongoose/lib/connection.js:788:12
at new Promise ()
at NativeConnection.Connection.openUri (/home/runner/url/node_modules/mongoose/lib/connection.js:785:19)
at /home/runner/url/node_modules/mongoose/lib/index.js:342:10
at /home/runner/url/node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:5
at new Promise ()
at promiseOrCallback (/home/runner/url/node_modules/mongoose/lib/helpers/promiseOrCallback.js:30:10)
at Mongoose.connect (/home/runner/url/node_modules/mongoose/lib/index.js:341:10)
at Object. (/home/runner/url/myApp.js:4:10)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
(node:2211) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see nodejs. org/ api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
(node:2211) [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.

Your code so far

const mongoose = require(‘mongoose’);
mongoose.connect(process.env.MONGO_URI, { useNewUrlParser: true, useUnifiedTopology: true });
/** 2) Create a ‘Person’ Model /
var personSchema = new mongoose.Schema({
name: { type: String, required: true },
age: Number,
favoriteFoods: [String]
* 3) Create and Save a Person */
var Person = mongoose.model(‘Person’, personSchema);
var createAndSavePerson = async function(done) {
var person = new Person({name: “Jane Fonda”, age: 84, favoriteFoods: [“vodka”, “air”]});, data) {
if (err) return console.error(err);
done(null, data)

Your browser information:

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

Challenge: Create and Save a Record of a Model

Link to the challenge:

I’ve been solving this for nearly 3 hours and I’ve finally found my solution.
My issue was that I was manually installing the packages,
when if they’re in the package.json dependencies, they automatically get installed when the repl gets run for the first/next time.
There must be some version discrepancy some where, the FCC code not being compatible with newer packages maybe?

I was running into this problem too (on I don’t know exactly how to solve it “correctly”. But I had to change

mongoose.connect(process.env.MONGO_URI, { useNewUrlParser: true, useUnifiedTopology: true });

to just


Then I had to remove the quotes I placed around my MONGO_URI in my .env file.

It gives a deprecation warning but at least it works, I guess… I couldn’t seem to find a solution using the new URL parser and proper quote formatting. If anyone knows and would like to share, that’d be cool.

Also if anyone is wondering like I was, for <dbname> in your Mongo URI you can replace it with anything, or manually create a database & collection in your MongoDB account by hitting the “collections” button on the cluster overview page, and fill in <dbname> with whatever you decide to name your database on the collections page.

Link to the original FCC challenge solution.