From 274e2f3d75c29451b05df29e39a62797ec5ad323 Mon Sep 17 00:00:00 2001 From: discountry Date: Sat, 8 Nov 2025 12:10:47 +0800 Subject: [PATCH] fix: improve WebSocket close reason normalization in LighterGateway for better error handling --- src/exchanges/lighter/gateway.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exchanges/lighter/gateway.ts b/src/exchanges/lighter/gateway.ts index ca1b86d..0bef4b0 100644 --- a/src/exchanges/lighter/gateway.ts +++ b/src/exchanges/lighter/gateway.ts @@ -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;