diff --git a/src/connection-manager/index.ts b/src/connection-manager/index.ts index 65de6efd49..39f36be006 100644 --- a/src/connection-manager/index.ts +++ b/src/connection-manager/index.ts @@ -254,10 +254,16 @@ export class DefaultConnectionManager extends EventEmitter> = [] for (const connectionList of this.connections.values()) { for (const connection of connectionList) { - tasks.push(connection.close()) + tasks.push((async () => { + try { + await connection.close() + } catch (err) { + log.error(err) + } + })()) } } diff --git a/src/upgrader.ts b/src/upgrader.ts index 109f2c2e80..27cd729ec9 100644 --- a/src/upgrader.ts +++ b/src/upgrader.ts @@ -382,9 +382,11 @@ export class DefaultUpgrader extends EventEmitter implements Upg getStreams: () => muxer != null ? muxer.streams : errConnectionNotMultiplexed(), close: async () => { await maConn.close() - // Ensure remaining streams are aborted + // Ensure remaining streams are closed if (muxer != null) { - muxer.streams.map(stream => stream.abort()) + await Promise.all(muxer.streams.map(async stream => { + await stream.close() + })) } } })