derbyjs / racer

Realtime model synchronization engine for Node.js
1.19k stars 118 forks source link

TypeError: Cannot read property '1' of undefined - totally unhelpful error message #126

Closed farmerpaul closed 11 years ago

farmerpaul commented 11 years ago

We have struggled with this error message multiple times as we've begun adding permissions checks to our Racer store - wasted hours on it already.

When you activate write permissions, by default all write requests are rejected. But instead of receiving a helpful error message from Racer, like Cannot write to model path '...' (which would be totally ideal) you get a much less relevant message instead:

TypeError: Cannot read property '1' of undefined
    at Object.module.exports.getId (/Users/paul/Projects/guideadvisor/node_modules/racer/lib/transaction.js:24:37)
    at Object.module.exports.server._commit.res.fail (/Users/paul/Projects/guideadvisor/node_modules/racer/lib/txns/txns.Model.js:339:43)
    at module.exports.events.init.store.eachContext.context.guardWrite.context.guardWrite (/Users/paul/Projects/guideadvisor/node_modules/racer/lib/accessControl/accessControl.Store.js:58:26)
    at next (/Users/paul/Projects/guideadvisor/node_modules/racer/lib/middleware.js:7:26)
    at guard (/Users/paul/Projects/guideadvisor/node_modules/racer/lib/accessControl/accessControl.Store.js:217:37)
    at next (/Users/paul/Projects/guideadvisor/node_modules/racer/lib/middleware.js:7:26)
    at Object.run [as guardWrite] (/Users/paul/Projects/guideadvisor/node_modules/racer/lib/middleware.js:10:12)
    at accessController (/Users/paul/Projects/guideadvisor/node_modules/racer/lib/txns/txns.Store.js:106:17)
    at next (/Users/paul/Projects/guideadvisor/node_modules/racer/lib/middleware.js:7:26)
    at Object.run (/Users/paul/Projects/guideadvisor/node_modules/racer/lib/middleware.js:10:12)
    at Model.module.exports.server._commit (/Users/paul/Projects/guideadvisor/node_modules/racer/lib/txns/txns.Model.js:347:29)
    at Model.module.exports.proto._sendOp (/Users/paul/Projects/guideadvisor/node_modules/racer/lib/txns/txns.Model.js:420:12)
    at Model.module.exports.proto.set.fn [as set] (/Users/paul/Projects/guideadvisor/node_modules/racer/lib/mutators/mutators.Model.js:99:21)
    at Model.module.exports.proto.setNull.fn [as setNull] (/Users/paul/Projects/guideadvisor/node_modules/racer/lib/mutators/mutators.Model.js:161:16)
...

I hope you'll consider improving this.

nateps commented 11 years ago

No longer relevant in 0.5