From a17bff79f311418963535a478641438c7852ce32 Mon Sep 17 00:00:00 2001 From: Timo Glastra Date: Mon, 2 May 2022 10:46:12 +0200 Subject: [PATCH] test: close session on agent shutdown Signed-off-by: Timo Glastra --- tests/transport/SubjectOutboundTransport.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/transport/SubjectOutboundTransport.ts b/tests/transport/SubjectOutboundTransport.ts index e099ccd506..385fcdc08c 100644 --- a/tests/transport/SubjectOutboundTransport.ts +++ b/tests/transport/SubjectOutboundTransport.ts @@ -1,7 +1,7 @@ import type { SubjectMessage } from './SubjectInboundTransport' import type { OutboundPackage, OutboundTransport, Agent, Logger } from '@aries-framework/core' -import { takeUntil, Subject } from 'rxjs' +import { takeUntil, Subject, take } from 'rxjs' import { InjectionSymbols, AriesFrameworkError } from '@aries-framework/core' @@ -45,6 +45,8 @@ export class SubjectOutboundTransport implements OutboundTransport { // Create a replySubject just for this session. Both ends will be able to close it, // mimicking a transport like http or websocket. Close session automatically when agent stops const replySubject = new Subject() + this.agent.config.stop$.pipe(take(1)).subscribe(() => !replySubject.closed && replySubject.complete()) + replySubject.pipe(takeUntil(this.agent.config.stop$)).subscribe({ next: async ({ message }: SubjectMessage) => { this.logger.test('Received message')