Skip to content

Commit

Permalink
clean up socks logging (#1285) (#1288)
Browse files Browse the repository at this point in the history
  • Loading branch information
dydxwill authored Mar 29, 2024
1 parent 1033ffd commit a6bd5dc
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions indexer/services/socks/src/helpers/wss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ export function sendMessageString(
at: 'wss#sendMessage',
message: 'Not sending message because websocket is not open',
connectionId,
messageContents: message,
readyState: ws.readyState,
});
stats.increment(
Expand All @@ -105,17 +104,21 @@ export function sendMessageString(
message: `Failed to send message: ${error.message}`,
error,
connectionId,
messageContents: message,
};
if (error?.message.includes?.('write EPIPE')) {
// This error means that the remote side of the stream has closed.
// ws should automatically call `close()`, so we shouldn't have to do it explicitly.
// Don't log an error as this can be expected if the client disconnects.
logger.info(errorLog);
stats.increment(
`${config.SERVICE_NAME}.ws_send.write_epipe_errors`,
);
} else if (error?.message.includes?.('write ECONNRESET')) {
// This error means that the client abruptly disconnected without sending a proper "close"
// message (or the message is delayed). In this case, we should terminate the connection
// immediately.
stats.increment(
`${config.SERVICE_NAME}.ws_send.write_econn_reset_errors`,
);
try {
ws.close(
WS_CLOSE_CODE_ABNORMAL_CLOSURE,
Expand All @@ -137,12 +140,10 @@ export function sendMessageString(
1,
{ action: 'close' },
);
logger.info(closeErrorLog);
} else {
logger.error(closeErrorLog);
}
}
logger.info(errorLog);
} else if (error?.message.includes?.(ERR_WRITE_STREAM_DESTROYED)) {
// This error means the underlying Socket was destroyed
// / Don't log an error as this can be expected when clients disconnect abruptly and can
Expand All @@ -152,7 +153,6 @@ export function sendMessageString(
1,
{ action: 'send' },
);
logger.info(errorLog);
} else {
logger.error(errorLog);
}
Expand Down

0 comments on commit a6bd5dc

Please sign in to comment.