@@ -56,8 +56,8 @@ const RECOVERABLE_DISCONNECT_REASONS: ReadonlySet<DisconnectReason> = new Set([
56
56
] ) ;
57
57
58
58
export interface SocketReservedEventsMap {
59
- disconnect : ( reason : DisconnectReason ) => void ;
60
- disconnecting : ( reason : DisconnectReason ) => void ;
59
+ disconnect : ( reason : DisconnectReason , description ?: any ) => void ;
60
+ disconnecting : ( reason : DisconnectReason , description ?: any ) => void ;
61
61
error : ( err : Error ) => void ;
62
62
}
63
63
@@ -749,14 +749,15 @@ export class Socket<
749
749
* Called upon closing. Called by `Client`.
750
750
*
751
751
* @param {String } reason
752
+ * @param description
752
753
* @throw {Error } optional error object
753
754
*
754
755
* @private
755
756
*/
756
- _onclose ( reason : DisconnectReason ) : this | undefined {
757
+ _onclose ( reason : DisconnectReason , description ?: any ) : this | undefined {
757
758
if ( ! this . connected ) return this ;
758
759
debug ( "closing socket - reason %s" , reason ) ;
759
- this . emitReserved ( "disconnecting" , reason ) ;
760
+ this . emitReserved ( "disconnecting" , reason , description ) ;
760
761
761
762
if ( RECOVERABLE_DISCONNECT_REASONS . has ( reason ) ) {
762
763
debug ( "connection state recovery is enabled for sid %s" , this . id ) ;
@@ -772,7 +773,7 @@ export class Socket<
772
773
this . nsp . _remove ( this ) ;
773
774
this . client . _remove ( this ) ;
774
775
this . connected = false ;
775
- this . emitReserved ( "disconnect" , reason ) ;
776
+ this . emitReserved ( "disconnect" , reason , description ) ;
776
777
return ;
777
778
}
778
779
0 commit comments