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

Issue

I’m opening a new issue on this because it is using GitPod. I am experiencing the same issue as this post last September. My submission is tested for a few moments, then gives a timed out error. I have confirmed that the connection is working and that the schema/model are created per specifications.

Code

let personSchema=new mongoose.Schema({
  name: {type: String, required: true},
  age: Number,
  favoriteFoods: [String]
});

// A model is a document instance. 
let Person=mongoose.model('Person',personSchema);
const createAndSavePerson = (done) => {
  // Creating a document instance of Person
  let Adrian=new Person({name:'Adrian',age:15,favoriteFoods:['Pizza','Apple Pie']});
  Adrian.save(function(error,data){
    if(error){
      console.log(error);
    }else{
      done(null,data);
    }
    
  });
};

solution: https://3000-freecodecam-boilerplate-4dckhpqfa11.ws-us108.gitpod.io

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36

Challenge Information:

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

The definition of timed out means the server is down or its not responding for some reason so I don’t see this as a client issue however there are workarounds.

Here are some troubleshooting resources for GitPod:

  • Contact Gitpod

You can contact Gitpod via their Support page if you can’t find your issue in the documentation.

  • Use Gitpod Dedicated

Gitpod Dedicated is a self-hosted, managed service that runs in your private cloud account.

  • Get started

You can add a .gitpod.yml at the root of your repository, use the gp init command to generate the .gitpod.yml file, and use the gp validate command to validate your configuration.

  • Configure Gitpod

You can try these steps to configure Gitpod:

  • Add no internet access over HTTPS (port 443) on Docker containers with a custom network

  • Use reference architectures to create an environment to install Gitpod into

  • Workspace lifecycle

All inactivity timeouts are dependent on an active editor or IDE connection. Closing your Gitpod connected editor or IDE will reduce the workspace timeout to 5 minutes.

You can also log in to Gitpod with your

GitLab

, GitHub, or

Bitbucket

account.

We need to see all your code. Post a repo or share the workspace.

When I submit I get a 500 back which usually suggests a server crash with these challenges. Do you not see any errors in the server console after you submit it and the tests run?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.