From f6a06b5fb342ba2d205151f15aa86fad1697645e Mon Sep 17 00:00:00 2001 From: Spencer Pogorzelski <34356756+Scoder12@users.noreply.github.com> Date: Mon, 14 Aug 2023 21:33:08 -0700 Subject: [PATCH] fix no async iteration over readablestream in chrome --- client/src/Connection.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/client/src/Connection.ts b/client/src/Connection.ts index a282d8f..3a1a6bf 100644 --- a/client/src/Connection.ts +++ b/client/src/Connection.ts @@ -19,6 +19,19 @@ type OpenWSMeta = { onerror: (message: string) => void; }; +(ReadableStream as any).prototype[Symbol.asyncIterator] = async function* () { + const reader = this.getReader(); + try { + while (true) { + const { done, value } = await reader.read(); + if (done) return; + yield value; + } + } finally { + reader.releaseLock(); + } +}; + export class Connection { requestCallbacks: Record = {}; openRequestStreams: Record> = {};