Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ Socket.prototype.onpacket = function(packet){
break;

case parser.ERROR:
this.emit('error', packet.data);
this.onerror(new Error(packet.data));
}
};

Expand Down
17 changes: 17 additions & 0 deletions test/socket.io.js
Original file line number Diff line number Diff line change
Expand Up @@ -1699,6 +1699,23 @@ describe('socket.io', function(){
});
});

it('should not crash when receiving an error packet without handler', function(done){
var srv = http();
var sio = io(srv);
srv.listen(function(){
var socket = client(srv, { reconnection: false });
sio.on('connection', function(s){
s.conn.on('upgrade', function(){
console.log('\033[96mNote: warning expected and normal in test.\033[39m');
socket.io.engine.write('44["handle me please"]');
setTimeout(function(){
done();
}, 100);
});
});
});
});

it('should not crash with raw binary', function(done){
var srv = http();
var sio = io(srv);
Expand Down