FabricLabs/soundtrack

Random error on service reset

Opened this issue · 3 comments

TypeError: /home/eric/soundtrack.io/views/index.jade:33
   31|             .btn-group
   32|               a.btn.btn-mini(href="#", data-action="skip-track") skip
 > 33|               if (user && room._owner && (user._id.toString() === room._owner._id.toString()) || (user && user.roles && ~user.roles.indexOf('admin')))
   34|                 a.btn.btn-mini(data-action="ban-track", data-for="current-track-id") ban
   35| 
   36|               if (user && user.roles.indexOf('editor') >= 0)

Cannot call method 'toString' of undefined
   at eval (eval at <anonymous> (/home/eric/soundtrack.io/node_modules/jade/lib/jade.js:164:8), <anonymous>:780:71)
   at /home/eric/soundtrack.io/node_modules/jade/lib/jade.js:165:35
   at Object.exports.render (/home/eric/soundtrack.io/node_modules/jade/lib/jade.js:199:14)
   at View.exports.renderFile [as engine] (/home/eric/soundtrack.io/node_modules/jade/lib/jade.js:226:13)
   at View.render (/home/eric/soundtrack.io/node_modules/express/lib/view.js:93:8)
   at EventEmitter.app.render (/home/eric/soundtrack.io/node_modules/express/lib/application.js:566:10)
   at ServerResponse.res.render (/home/eric/soundtrack.io/node_modules/express/lib/response.js:938:7)
   at /home/eric/soundtrack.io/controllers/pages.js:48:11
   at /home/eric/soundtrack.io/node_modules/async/lib/async.js:232:13
   at /home/eric/soundtrack.io/node_modules/async/lib/async.js:119:25

I see this a after upgrading to a newer git hash and restarting my service. It seems like a temporary error that a logout / login or return to core room listing / re-entering room fixes.

My only guess is it hasn't connected to mongo yet so user._id is still undefined.

My only guess is it hasn't connected to mongo yet so user._id is still undefined.

This problem persists even after connecting to mongo, all the way up to viewing the very front page of your instance. I suspect there's some reference getting updated on the viewing of that page (related to the population of the room._owner object). Maybe we can use git bisect between current and whatever your previous commit was, @diginc?

I had this my past 2 upgrades...the 2nd to latest upgrade I freaked out and reverted to older and older hashes until the error went away. Then I rolled forward 1 hash at a time and couldn't reproduce so went back to latest.

The reason I became convinced it was a service restart/startup issue was the past upgrade I did was from before the #185 Merge to #187 revert of that merge...so no code actually changed, I just ran a service soundtrack restart to restart node.

I dropped this reminder to my self of the hashes and the error on my server:

root@magus /home/soundtrack/soundtrack.io (soundtrack.io) $ cat upgrades.txt 
2016/02/05 old hash: 587366fdb70958f8a72c0f5c3ba9983104c89786
2016/02/05 new hash: 1ee3fbb31e57d1bd09af82dae0945879ddd1bf14

TypeError: /home/soundtrack/soundtrack.io/views/index.jade:33
   31|             .btn-group
   32|               a.btn.btn-mini(href="#", data-action="skip-track") skip
 > 33|               if (user && room._owner && (user._id.toString() === room._owner._id.toString()) || (user && user.roles && ~user.roles.indexOf('admin')))
   34|                 a.btn.btn-mini(data-action="ban-track", data-for="current-track-id") ban
   35| 
   36|               if (user && user.roles.indexOf('editor') >= 0)

Cannot call method 'toString' of undefined
   at eval (eval at <anonymous> (/home/soundtrack/soundtrack.io/node_modules/jade/lib/jade.js:164:8), <anonymous>:780:71)
   at /home/soundtrack/soundtrack.io/node_modules/jade/lib/jade.js:165:35
   at Object.exports.render (/home/soundtrack/soundtrack.io/node_modules/jade/lib/jade.js:199:14)
   at View.exports.renderFile [as engine] (/home/soundtrack/soundtrack.io/node_modules/jade/lib/jade.js:226:13)
   at View.render (/home/soundtrack/soundtrack.io/node_modules/express/lib/view.js:126:8)
   at tryRender (/home/soundtrack/soundtrack.io/node_modules/express/lib/application.js:639:10)
   at EventEmitter.render (/home/soundtrack/soundtrack.io/node_modules/express/lib/application.js:591:3)
   at ServerResponse.render (/home/soundtrack/soundtrack.io/node_modules/express/lib/response.js:961:7)
   at /home/soundtrack/soundtrack.io/controllers/pages.js:43:11
   at /home/soundtrack/soundtrack.io/node_modules/async/lib/async.js:232:13

I'll upload my /etc/init.d service and start.sh script if you think it has something to do with the way I restart.

Edit: shell scripts here: https://gist.github.com/diginc/f54a5d7c6e7e66e28a40