Skip to content

Commit

Permalink
test: close session on agent shutdown
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Glastra <timo@animo.id>
  • Loading branch information
TimoGlastra committed May 2, 2022
1 parent 1fd017d commit a17bff7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tests/transport/SubjectOutboundTransport.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -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<SubjectMessage>()
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')
Expand Down

0 comments on commit a17bff7

Please sign in to comment.