Skip to content

Browser Client Minification breaks Payload encoding/decoding #422

@abdulmueid

Description

@abdulmueid

The minified browser client breaks the encoding/decoding of Payloads in the browser when using XHR-Polling.

Here is the code to reproduce the bug:

var io = io.listen(8080);
io.enable('browser client minification');  // send minified client
io.set('transports', ['xhr-polling']);
io.sockets.on('connection', function(client){
    client.on('message',function(msg){
        //Send messages in succession to create a payload
        client.send("Hello");
        client.send("Hello!");
        client.send("Hello!!");
        client.send("Hello!!!");
        client.send("Hello!!!!");
        console.log(msg);
    });
});

Code on the client side:

<html>
<head>
<script src="http://localhost:11027/socket.io/socket.io.js"></script>
<script>
    var socket = io.connect('http://localhost:11027');
    socket.on('message', function (msg) {
        document.getElementById('out').innerHTML = "<div>"+msg+"</div>" + document.getElementById('out').innerHTML;
    });
    function sendPayload() {
        //Send messages in succession to create a payload
        socket.send("Hello");
        socket.send("Hello!");
        socket.send("Hello!!");
        socket.send("Hello!!!");
        socket.send("Hello!!!!");       
    }

</script>
</head>
<body>
<button onClick="sendPayload();">Send Payload</button>
<div id="out"></div>
</body>
</html>

Upon clicking "Send Payload" button on the web page, we expect 5 "hello" on the server console and 25 "hello" on the client output. Only one arrives on each side.

Removing the client minification string from server side fixes the problem.

Tested on socket.io version 0.7.7, installed using NPM.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions