Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add typechecking to Socket#pack to avoid parsing undefined #125

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add typechecking to Socket#pack to avoid parsing undefined #125

wants to merge 1 commit into from

Conversation

skeggse
Copy link

@skeggse skeggse commented Mar 28, 2014

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 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.

Fixes #124 provided we can make the tests work.

Signed-off-by: Eli Skeggs <[email protected]>
push.send(undefined);
}, /undefined/, 'send should reject unserializable types');
assert.throws(function() {
push.send(null, undefined);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this test, should probably ensure that push.send(null) still works.

@navaru
Copy link

navaru commented Aug 17, 2015

@skeggse is this still valid? Otherwise can you please close the issue

@skeggse
Copy link
Author

skeggse commented Aug 17, 2015

Yes, this appears to still be an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SyntaxError: Unexpected token u
2 participants