Skip to content

Commit

Permalink
Readd opt-in verboseMessageLogs debugging messages
Browse files Browse the repository at this point in the history
Vendr needs it still, and it's a good thing to have in there just in
case to help debug even future issues. We'll keep it behind the
undocumented flag for now.
  • Loading branch information
jacobmischka committed Jun 28, 2023
1 parent 8de03b3 commit 8761590
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/classes/IntervalClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export default class IntervalClient {
environment: ActionEnvironment | undefined
#forcePeerMessages = false

#verboseMessageLogs = false
#onError: IntervalErrorHandler | undefined

constructor(interval: Interval, config: InternalConfig) {
Expand Down Expand Up @@ -194,6 +195,10 @@ export default class IntervalClient {
if (config.onError) {
this.#onError = config.onError
}

if (config.verboseMessageLogs) {
this.#verboseMessageLogs = config.verboseMessageLogs
}
}

async #walkRoutes() {
Expand Down Expand Up @@ -760,6 +765,12 @@ export default class IntervalClient {
}
)

if (this.#verboseMessageLogs) {
ws.onMessage.attach(message => {
this.#logger.debug('Message received:', message)
})
}

ws.onClose.attach(async ([code, reason]) => {
if (this.#intentionallyClosed) {
this.#intentionallyClosed = false
Expand Down Expand Up @@ -811,10 +822,6 @@ export default class IntervalClient {

await ws.connect()

ws.onMessage.attach(data => {
this.#logger.debug('Message received:', data)
})

this.#ws = ws

let lastSuccessfulPing = new Date()
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export interface InternalConfig {
closeUnresponsiveConnectionTimeoutMs?: number
reinitializeBatchTimeoutMs?: number
onError?: IntervalErrorHandler
verboseMessageLogs?: boolean

/* @internal */ getClientHandlers?: () =>
| DuplexRPCHandlers<ClientSchema>
Expand Down

0 comments on commit 8761590

Please sign in to comment.