File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ export class Session {
4646 private _wampSession : WAMPSession ;
4747 private _idGen : SessionScopeIDGenerator = new SessionScopeIDGenerator ( ) ;
4848 private _disconnectCallbacks : Array < ( reason ?: string ) => Promise < void > > = [ ] ;
49+ private _disconnected = false ;
4950
5051 private _callRequests : Map < number , {
5152 resolve : ( value : Result ) => void ,
@@ -98,7 +99,8 @@ export class Session {
9899 return ;
99100 }
100101
101- throw err ;
102+ // Transport read failed, treat it as a disconnect.
103+ await this . markDisconnected ( err instanceof globalThis . Error ? err . message : String ( err ) ) ;
102104 }
103105 } ) ( ) ;
104106 }
@@ -344,6 +346,9 @@ export class Session {
344346 }
345347
346348 private async markDisconnected ( reason ?: string ) {
349+ if ( this . _disconnected ) return ;
350+ this . _disconnected = true ;
351+
347352 if ( this . _disconnectCallbacks . length > 0 ) {
348353 await Promise . all ( this . _disconnectCallbacks . map ( cb => cb ( reason ) ) ) ;
349354 }
You can’t perform that action at this time.
0 commit comments