Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update recursive backoff & trust ping record updates #631

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,10 @@ export class ConnectionService {
// - maybe this shouldn't be in the connection service?
const trustPing = new TrustPingMessage(config)

await this.updateState(connectionRecord, ConnectionState.Complete)
// Only update connection record and emit an event if the state is not already 'Complete'
if (connectionRecord.state !== ConnectionState.Complete) {
await this.updateState(connectionRecord, ConnectionState.Complete)
}

return {
connectionRecord: connectionRecord,
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/modules/routing/RecipientModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import type { ConnectionRecord } from '../connections'
import type { MediationStateChangedEvent } from './RoutingEvents'
import type { MediationRecord } from './index'

import { firstValueFrom, interval, ReplaySubject } from 'rxjs'
import { filter, first, takeUntil, throttleTime, timeout, delay, tap } from 'rxjs/operators'
import { firstValueFrom, interval, ReplaySubject, timer } from 'rxjs'
import { filter, first, takeUntil, throttleTime, timeout, tap, delayWhen } from 'rxjs/operators'
import { Lifecycle, scoped } from 'tsyringe'

import { AgentConfig } from '../../agent/AgentConfig'
Expand Down Expand Up @@ -140,7 +140,7 @@ export class RecipientModule {
// Increase the interval (recursive back-off)
tap(() => (interval *= 2)),
// Wait for interval time before reconnecting
delay(interval)
delayWhen(() => timer(interval))
)
.subscribe(async () => {
this.logger.warn(
Expand Down