faye/faye-websocket-node

Passing a number to WebSocket.Client.send() fails.

Closed this issue · 4 comments

There's an easy workaround, but Chrome, Safari, and Firefox all permit this (they convert the number to a string for you). So for compatibility, it'd be cool if faye-websocket did too.

TypeError: Object 1 has no method 'copy'
at [object Object].frame (/Users/michael/src/node_modules/faye-websocket/lib/faye/websocket/hybi_parser.js:236:12)
at [object Object].send (/Users/michael/src/node_modules/faye-websocket/lib/faye/websocket/api.js:46:30)

Not to shoot the messanger but that is a mind-numbingly stupid decision by browser makers. Nowhere in the spec does it say that send(Number) is a valid call, and given sockets support binary data I would rather this case were treated as ambiguous.

Still, if it's in browsers and I'm aiming for a portable implementation, I guess I'm going to have to implement it.

Fixed in 8c9ae84.

That was quick, thanks!

Shipped in 0.4.1. Any object that's not a Buffer will be treated as a string by WebSocket.send().