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;