Skip to content

Commit 4ffb62b

Browse files
committed
add logs
1 parent f85a9b1 commit 4ffb62b

File tree

2 files changed

+18
-24
lines changed

2 files changed

+18
-24
lines changed

src/connection-manager/connections.ts

+17-23
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,6 @@ async function setHandlers(
6161
isInitialNode = false,
6262
retryCount = 0,
6363
): Promise<void> {
64-
// log.info(
65-
// `Initiated Websocket connection for: ${ws_url} on ${
66-
// networks ?? 'unknown network'
67-
// }`,
68-
// )
69-
7064
const ledger_hashes: string[] = []
7165
return new Promise(function setHandlersPromise(resolve, _reject) {
7266
ws.on('open', () => {
@@ -124,21 +118,21 @@ async function setHandlers(
124118
)
125119
}
126120
})
127-
ws.on('close', async (code) => {
128-
// log.error(
129-
// `Websocket closed for ${ws.url} on ${
130-
// networks ?? 'unknown network'
131-
// } with code ${code} and reason ${reason.toString('utf-8')}.`,
132-
// )
121+
ws.on('close', async (code, reason) => {
122+
log.error(
123+
`Websocket closed for ${ws.url} on ${
124+
networks ?? 'unknown network'
125+
} with code ${code} and reason ${reason.toString('utf-8')}.`,
126+
)
133127

134128
const delay = BASE_RETRY_DELAY * 2 ** retryCount
135129

136130
if (CLOSING_CODES.includes(code) && delay <= MAX_RETRY_DELAY) {
137-
// log.info(
138-
// `Reconnecting to ${ws.url} on ${
139-
// networks ?? 'unknown network'
140-
// } after ${delay}ms...`,
141-
// )
131+
log.info(
132+
`Reconnecting to ${ws.url} on ${
133+
networks ?? 'unknown network'
134+
} after ${delay}ms...`,
135+
)
142136
// Clean up the old Websocket connection
143137
connections.delete(ws.url)
144138
ws.terminate()
@@ -168,12 +162,12 @@ async function setHandlers(
168162
ws.terminate()
169163
resolve()
170164
})
171-
ws.on('error', () => {
172-
// log.error(
173-
// `Websocket connection error for ${ws.url} on ${
174-
// networks ?? 'unknown network'
175-
// } - ${err.message}`,
176-
// )
165+
ws.on('error', (err) => {
166+
log.error(
167+
`Websocket connection error for ${ws.url} on ${
168+
networks ?? 'unknown network'
169+
} - ${err.message}`,
170+
)
177171

178172
if (connections.get(ws.url)?.url === ws.url) {
179173
connections.delete(ws.url)

src/connection-manager/wsHandling.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function isFlagLedgerPlusOne(ledger_index: number): boolean {
101101
* @param networks - The networks of subscribed node.
102102
* @param network_fee - The map of default fee for the network to be used in case the validator does not vote for a new fee.
103103
* @param ws - The WebSocket message received from.
104-
* @param validationNetworkDb -- The validation network map to fetch fee data.
104+
* @param validationNetworkDb -- A map of validator signing_keys to their corresponding networks.
105105
* @returns Void.
106106
*/
107107
// eslint-disable-next-line max-params -- Disabled for this function.

0 commit comments

Comments
 (0)