visionmedia/axon — pull request #125 by skeggse (2014-03-28 16:59:09+00:00)
Title: Add typechecking to Socket#pack to avoid parsing undefined

Fixes #124 provided we can make the tests work.

> Alright, so I can make the tests fail by adding `push.send(undefined);` to line 16 of `test.arg-types.js`, simply because it causes the `Unexpected token u` SyntaxError.

> The message is then encoded as a buffer containing `110000000b6a3a756e646566696e6564`, which includes `j:undefined`. That means that, as confirmed by walking through with Node's debugger, the `JSON.stringify` [line](https://github.com/visionmedia/node-amp-message/blob/10cdca4158dc21ae80730758ab62dd4ac0904ee1/index.js#L123) in node-amp-message is being passed `undefined`, which returns `undefined`, which is coerced into the string `'undefined'`. I'm wondering whether this would be more suited for amp-message rather than axon, given that we're not currently looping through the args before buffering them in `Socket#pack`.

> Also, given that `send` usually queues messages until the socket is actually ready, the error won't be thrown until the socket is ready which means I can't use `assert.throws` in the test case.