Skip to content

Commit

Permalink
DF-19232 add new UrlSubscriptionWebsocketTransport type which logs UR…
Browse files Browse the repository at this point in the history
…L changes at debug level rather than info since frequent changes are expected
  • Loading branch information
mmcallister-cll committed Oct 5, 2023
1 parent 194f37a commit c282c92
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/transports/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export class WebSocketTransport<
currentUrl = ''
lastMessageReceivedAt = 0
connectionOpenedAt = 0
isUrlSubscriptionWebsocket = false

constructor(private config: WebSocketTransportConfig<T>) {
super()
Expand Down Expand Up @@ -329,7 +330,8 @@ export class WebSocketTransport<
const reason = urlChanged
? `Websocket url has changed from ${this.currentUrl} to ${urlFromConfig}, closing connection...`
: `Last message was received ${timeSinceLastMessage} ago, exceeding the threshold of ${context.adapterSettings.WS_SUBSCRIPTION_UNRESPONSIVE_TTL}ms, closing connection...`
censorLogs(() => logger.info(reason))
const logfn = urlChanged && this.isUrlSubscriptionWebsocket ? logger.debug : logger.info
censorLogs(() => logfn(reason))

// Check if connection was opened very recently; if so, wait a bit before continuing.
// This is so if we just opened the connection and are waiting to receive some messages,
Expand Down Expand Up @@ -466,3 +468,10 @@ export class WebsocketReverseMappingTransport<
return this.requestMapping.get(value)
}
}

export class UrlSubscriptionWebsocketTransport<T extends WebsocketTransportGenerics> extends WebSocketTransport<T> {
constructor(config: WebSocketTransportConfig<T>) {
super(config)
this.isUrlSubscriptionWebsocket = true
}
}

0 comments on commit c282c92

Please sign in to comment.