Skip to content

Commit

Permalink
feat: update recursive backoff & trust ping record updates (#631)
Browse files Browse the repository at this point in the history
Signed-off-by: James Ebert <[email protected]>
  • Loading branch information
JamesKEbert authored Feb 8, 2022
1 parent beff6b0 commit f64a9da
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
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

0 comments on commit f64a9da

Please sign in to comment.