alabid / flylatex

FlyLatex: A Realtime Collaborative Environment (with a concurrent editor) in node-js.
766 stars 85 forks source link

Node app.js error #17

Closed kaanaksit closed 11 years ago

kaanaksit commented 11 years ago

I sometimes receive this error during node app.js and the application closes itself:

/home/kaan/flylatex/node_modules/mongoose/lib/utils.js:413 throw err; ^ TypeError: Cannot read property 'length' of undefined at searchForDocsInSession (/home/kaan/flylatex/routes.js:1472:46) at Promise. (/home/kaan/flylatex/routes.js:1344:17) at Promise. (/home/kaan/flylatex/node_modules/mongoose/lib/promise.js:120:8) at Promise.EventEmitter.emit (events.js:95:17) at Promise.emit (/home/kaan/flylatex/node_modules/mongoose/lib/promise.js:59:38) at Promise.complete (/home/kaan/flylatex/node_modules/mongoose/lib/promise.js:70:20) at /home/kaan/flylatex/node_modules/mongoose/lib/query.js:1086:15 at model.Document.init (/home/kaan/flylatex/node_modules/mongoose/lib/document.js:199:11) at model.init (/home/kaan/flylatex/node_modules/mongoose/lib/model.js:182:36) at /home/kaan/flylatex/node_modules/mongoose/lib/query.js:1084:12 at /home/kaan/flylatex/node_modules/mongoose/lib/utils.js:408:16 at /home/kaan/flylatex/node_modules/mongoose/node_modules/mongodb/lib/mongodb/collection.js:882:34 at /home/kaan/flylatex/node_modules/mongoose/node_modules/mongodb/lib/mongodb/cursor.js:133:9 at /home/kaan/flylatex/node_modules/mongoose/node_modules/mongodb/lib/mongodb/cursor.js:173:11 at /home/kaan/flylatex/node_modules/mongoose/node_modules/mongodb/lib/mongodb/cursor.js:467:35 at Cursor.close (/home/kaan/flylatex/node_modules/mongoose/node_modules/mongodb/lib/mongodb/cursor.js:687:5) at Cursor.nextObject (/home/kaan/flylatex/node_modules/mongoose/node_modules/mongodb/lib/mongodb/cursor.js:467:17) at /home/kaan/flylatex/node_modules/mongoose/node_modules/mongodb/lib/mongodb/cursor.js:165:12 at process._tickCallback (node.js:415:13)

alabid commented 11 years ago

I think I fixed the error via some more error checking. The problem was that the callback to find a document was sometimes being called after the document was closed (a significant lag in callback execution).

kaanaksit commented 11 years ago

I haven't come across the same problem lately with the new code. Thanks!