From 45c8b92a020d867385dbd1097206ef957c4db541 Mon Sep 17 00:00:00 2001 From: Roscoe Rubin-Rottenberg Date: Sat, 4 Oct 2025 20:30:02 -0400 Subject: [PATCH] shrugs --- xrpc-server/stream/server.ts | 2 +- xrpc-server/stream/stream.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/xrpc-server/stream/server.ts b/xrpc-server/stream/server.ts index 6547660..5939ed7 100644 --- a/xrpc-server/stream/server.ts +++ b/xrpc-server/stream/server.ts @@ -86,7 +86,7 @@ export class XrpcStreamServer { } } catch (err) { if (err instanceof DisconnectError) { - socket.close(err.wsCode, String(err.xrpcCode ?? "")); + socket.close(err.wsCode, err.message); return; } else { logger.error("websocket server error", { err }); diff --git a/xrpc-server/stream/stream.ts b/xrpc-server/stream/stream.ts index 458aba6..1461ca4 100644 --- a/xrpc-server/stream/stream.ts +++ b/xrpc-server/stream/stream.ts @@ -2,10 +2,10 @@ import { ResponseType, XRPCError } from "@atp/xrpc"; import { Frame, type MessageFrame } from "./frames.ts"; /** Convert any WebSocket .data variant into a Uint8Array */ -function toUint8Array(data: unknown): Uint8Array { +async function toUint8Array(data: unknown): Promise { if (data instanceof Uint8Array) return data; if (data instanceof ArrayBuffer) return new Uint8Array(data); - if (data instanceof Blob) return new Uint8Array(data.size ? [] : []); // we'll handle Blob async below + if (data instanceof Blob) return new Uint8Array(await data.arrayBuffer()); // we'll handle Blob async below if (typeof data === "string") { // If your protocol *only* sends binary, you could throw here. return new TextEncoder().encode(data); @@ -51,7 +51,7 @@ export function iterateBinary(ws: WebSocket): AsyncIterable { const buf = await ev.data.arrayBuffer(); bytes = new Uint8Array(buf); } else { - bytes = toUint8Array(ev.data); + bytes = await toUint8Array(ev.data); } queue.push(bytes); pump(); -- 2.51.2