File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -392,6 +392,22 @@ export class Peer extends EventEmitter<PeerEvents> {
392392 PeerErrorType . PeerUnavailable ,
393393 `Could not connect to peer ${ peerId } ` ,
394394 ) ;
395+
396+ // This is so that an error is emited on a connection that has just been created,
397+ // but could not be established because the server responded with
398+ // `ServerMessageType.Expire` (but yes, we emit the error on all connections).
399+ // See https://github.com/peers/peerjs/issues/924
400+ //
401+ // TODO how about `this._cleanupPeer(peerId);` instead?
402+ // Or how about make the server send back `connectionId`, and only emit the error
403+ // on that connection?
404+ const connections = this . _connections . get ( peerId ) ;
405+ if ( connections ) {
406+ for ( const c of connections ) {
407+ c . emit ( "error" , new Error ( `Server says ${ peerId } is unavailable` ) ;
408+ }
409+ }
410+
395411 break ;
396412 case ServerMessageType . Offer : {
397413 // we should consider switching this to CALL/CONNECT, but this is the least breaking option.
You can’t perform that action at this time.
0 commit comments