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,10 @@ export class Session {
9899 return ;
99100 }
100101
101- throw err ;
102+ // Transport read failed (socket closed/errored) — treat this the
103+ // same as a disconnect, mirroring xconn-go's waitForRouterMessages,
104+ // instead of relying solely on the peer's own onDisconnect wiring.
105+ await this . markDisconnected ( err instanceof globalThis . Error ? err . message : String ( err ) ) ;
102106 }
103107 } ) ( ) ;
104108 }
@@ -344,6 +348,9 @@ export class Session {
344348 }
345349
346350 private async markDisconnected ( reason ?: string ) {
351+ if ( this . _disconnected ) return ;
352+ this . _disconnected = true ;
353+
347354 if ( this . _disconnectCallbacks . length > 0 ) {
348355 await Promise . all ( this . _disconnectCallbacks . map ( cb => cb ( reason ) ) ) ;
349356 }
You can’t perform that action at this time.
0 commit comments