Strange Node.JS error

I have running in my Mac a Node.JS server, and, I access to it from other computer, the server doesn't crash, but, I don't know why, the application crashes when I access from my iPad. If I access from Safari, the server works, but, with Chrome for iPad, the app crash!

This is the error: TypeError: Cannot read property 'following' of null. Why this happens?

EDITED:

app.get('/home', middleware.yeses, function (req, res){

 console.log(req.session.user + "\n\n");

 UserModel.find({ user: req.session.user }, function (err, user){

      console.log(user);

      res.render('home.ejs', {

         username: req.session.user,
         avatar: user[0].avatar,            
         following: user[0].following.length,
         followers: user[0].followers.length

      }); 

  });

});

EDITED:

I changed the console.log(user); to this console.log(user[0].following). And there's no problem. I don't know why, there's a problem with it in the locals.

This occurs because the JavaScript is throwing an exception. Somewhere in the code, the there is a variable that is assigned to null and the property following is being accessed on that variable. This operation raises an exception.

var obj = null;
obj.following; // exception thrown!

It's impossible to help you more. With the info and code you've provided (very little of either). But look for where you are accessing a following property and debug from there.


Update:

It appears user[0] is null. Why? No idea. That depends on other code you haven't posted. WHere is user declared and populated? Is it an array? Because that would be strange for a variable named user.