mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-09 08:18:07 +00:00
fix: improve WebSocket close reason normalization in LighterGateway for better error handling
This commit is contained in:
@@ -488,7 +488,7 @@ export class LighterGateway {
|
||||
});
|
||||
ws.on("close", (code, reason) => {
|
||||
cleanup();
|
||||
const normalizedReason = typeof reason === "string" && reason.length ? reason : undefined;
|
||||
const normalizedReason = Buffer.isBuffer(reason) && reason.length > 0 ? reason.toString("utf8") : undefined;
|
||||
if (!settled) {
|
||||
fail(new Error(`WebSocket closed before ready (code=${code}${normalizedReason ? `, reason=${normalizedReason}` : ""})`));
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user