diff --git a/packages/integration-tests/test/circuit-relay.node.ts b/packages/integration-tests/test/circuit-relay.node.ts index b829c08e12..57d1cf95c5 100644 --- a/packages/integration-tests/test/circuit-relay.node.ts +++ b/packages/integration-tests/test/circuit-relay.node.ts @@ -519,8 +519,8 @@ describe('circuit-relay', () => { await deferred.promise // should have closed connections to remote and to relay - expect(events[0].detail.remotePeer.toString()).to.equal(relay1.peerId.toString()) - expect(events[1].detail.remotePeer.toString()).to.equal(remote.peerId.toString()) + expect(events[0].detail.remotePeer.toString()).to.equal(remote.peerId.toString()) + expect(events[1].detail.remotePeer.toString()).to.equal(relay1.peerId.toString()) }) it('should mark an outgoing relayed connection as limited', async () => { diff --git a/packages/utils/src/abstract-stream.ts b/packages/utils/src/abstract-stream.ts index a92810d0e4..125660256f 100644 --- a/packages/utils/src/abstract-stream.ts +++ b/packages/utils/src/abstract-stream.ts @@ -284,6 +284,10 @@ export abstract class AbstractStream implements Stream { // Close for both Reading and Writing async close (options?: AbortOptions): Promise { + if (this.status !== 'open') { + return + } + this.log.trace('closing gracefully') this.status = 'closing'