Closed jtomaszon closed 4 years ago
Can you post the full output (from execution of heimcontrol to error) and details about your system (which versions of mongodb, node)? Thanks.
node heimcontrol.js
info - socket.io started
connect.multipart() will be removed in connect 3.0
visit https://github.com/senchalabs/connect/wiki/Connect-3.0 for alternatives
connect.limit() will be removed in connect 3.0
heimcontrol.js listening on port 8080
GET / 302 265ms - 68b
/root/heimcontrol.js/node_modules/mongodb/lib/mongodb/connection/base.js:242
throw message;
^
TypeError: Cannot read property 'length' of null
at /root/heimcontrol.js/routes/index.js:449:14
at /root/heimcontrol.js/node_modules/mongodb/lib/mongodb/cursor.js:159:22
at /root/heimcontrol.js/node_modules/mongodb/lib/mongodb/cursor.js:685:39
at Cursor.close (/root/heimcontrol.js/node_modules/mongodb/lib/mongodb/cursor.js:959:5)
at commandHandler (/root/heimcontrol.js/node_modules/mongodb/lib/mongodb/cursor.js:685:21)
at /root/heimcontrol.js/node_modules/mongodb/lib/mongodb/db.js:1806:9
at Server.Base._callHandler (/root/heimcontrol.js/node_modules/mongodb/lib/mongodb/connection/base.js:442:41)
at /root/heimcontrol.js/node_modules/mongodb/lib/mongodb/connection/server.js:485:18
at MongoReply.parseBody (/root/heimcontrol.js/node_modules/mongodb/lib/mongodb/responses/mongo_reply.js:68:5)
at null.<anonymous> (/root/heimcontrol.js/node_modules/mongodb/lib/mongodb/connection/server.js:443:20)
node version
root@pihome ~/heimcontrol.js # node --version
v0.10.29
I'm using mongolabs for mongodb (2.4) external db
To check that problem.. here is my diff
@@ -446,7 +446,7 @@ define([ 'crypto', 'cookie', 'fs' ], function(crypto, cookie, fs) {
// If no user exists, redirect to register
req.app.get('db').collection('User', function(err, u) {
u.find({}).toArray(function(err, r) {
- if (r.length == 0) {
+ if (typeof r !== "undefined" || r.length == 0) {
return res.redirect('/register');
} else {
var c = cookie.parse(req.headers.cookie);
Hi all, I installed heimcontrol from scratch without any collection on my mongodb install. After start, I'm receiving: TypeError: Cannot read property 'length' of null every time that do some find on the mongodb collection. Could you please add some "init" for db to avoid that?
mongodb #init #data