ottypes/json0 — pull request #5 by ishbu (2014-12-31 02:23:16+00:00)
Title: Do a more complete object type check to catch case that elem is undefined

We've been seeing a rare occurence issue where elem during json.checkObj in apply is called on an undefined elem.

Still not sure of the root cause of the issue. But I believe this is a better object check that results in the error being thrown properly. Otherwise you get a stack trace like:

TypeError: Cannot read property 'constructor' of undefined
at Object.json.checkObj (/var/lever/hire2/node_modules/derby/node_modules/racer/node_modules/share/node_modules/ottypes/lib/json0.js:103:11)
at Object.json.apply (/var/lever/hire2/node_modules/derby/node_modules/racer/node_modules/share/node_modules/ottypes/lib/json0.js:204:12)
at Object.json.incrementalApply (/var/lever/hire2/node_modules/derby/node_modules/racer/node_modules/share/node_modules/ottypes/lib/json0.js:240:21)
at Doc._otApply (/var/lever/hire2/node_modules/derby/node_modules/racer/node_modules/share/lib/client/doc.js:667:12)
at Doc._onMessage (/var/lever/hire2/node_modules/derby/node_modules/racer/node_modules/share/lib/client/doc.js:379:12)
at Connection.handleMessage (/var/lever/hire2/node_modules/derby/node_modules/racer/node_modules/share/lib/client/connection.js:215:37)
at StreamSocket.socket.onmessage (/var/lever/hire2/node_modules/derby/node_modules/racer/node_modules/share/lib/client/connection.js:124:18)
at StreamSocket.Channel.socket.onmessage (/var/lever/hire2/node_modules/derby/node_modules/racer/lib/Channel.js:19:28)
at Duplex._write (/var/lever/hire2/node_modules/derby/node_modules/racer/lib/Model/connection.server.js:23:12)