File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 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){
340340 break ;
341341
342342 case parser . ERROR :
343- this . emit ( 'error' , packet . data ) ;
343+ this . onerror ( new Error ( packet . data ) ) ;
344344 }
345345} ;
346346
Original file line number Diff line number Diff line change @@ -1699,6 +1699,23 @@ describe('socket.io', function(){
16991699 } ) ;
17001700 } ) ;
17011701
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+
17021719 it ( 'should not crash with raw binary' , function ( done ) {
17031720 var srv = http ( ) ;
17041721 var sio = io ( srv ) ;
You can’t perform that action at this time.
0 commit comments