File tree 2 files changed +18
-1
lines changed
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -340,7 +340,7 @@ Socket.prototype.onpacket = function(packet){
340
340
break ;
341
341
342
342
case parser . ERROR :
343
- this . emit ( 'error' , packet . data ) ;
343
+ this . onerror ( new Error ( packet . data ) ) ;
344
344
}
345
345
} ;
346
346
Original file line number Diff line number Diff line change @@ -1699,6 +1699,23 @@ describe('socket.io', function(){
1699
1699
} ) ;
1700
1700
} ) ;
1701
1701
1702
+ it ( 'should not crash when receiving an error packet without handler' , function ( done ) {
1703
+ var srv = http ( ) ;
1704
+ var sio = io ( srv ) ;
1705
+ srv . listen ( function ( ) {
1706
+ var socket = client ( srv , { reconnection : false } ) ;
1707
+ sio . on ( 'connection' , function ( s ) {
1708
+ s . conn . on ( 'upgrade' , function ( ) {
1709
+ console . log ( '\033[96mNote: warning expected and normal in test.\033[39m' ) ;
1710
+ socket . io . engine . write ( '44["handle me please"]' ) ;
1711
+ setTimeout ( function ( ) {
1712
+ done ( ) ;
1713
+ } , 100 ) ;
1714
+ } ) ;
1715
+ } ) ;
1716
+ } ) ;
1717
+ } ) ;
1718
+
1702
1719
it ( 'should not crash with raw binary' , function ( done ) {
1703
1720
var srv = http ( ) ;
1704
1721
var sio = io ( srv ) ;
You can’t perform that action at this time.
0 commit comments