@ai-ecoverse/slicc-kernel 1.46.0 → 1.46.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9626,13 +9626,16 @@ function websocketOp(kernel) {
9626
9626
  const writable2 = new WritableStream({
9627
9627
  async write(chunk, controller) {
9628
9628
  stop.signal.throwIfAborted();
9629
- const body = typeof chunk === "string" ? { text: chunk } : { body: chunk };
9630
- let buffered = await kernel.json({ op: "net-ws-send", handle, ...body });
9629
+ const send = async (body) => {
9630
+ if (settled) throw new JsCallError("EPIPE", "the websocket is closed");
9631
+ return await kernel.json({ op: "net-ws-send", handle, ...body });
9632
+ };
9633
+ let buffered = await send(typeof chunk === "string" ? { text: chunk } : { body: chunk });
9631
9634
  while (buffered > SEND_BUFFER) {
9632
9635
  await wait(10);
9633
9636
  stop.signal.throwIfAborted();
9634
9637
  controller.signal.throwIfAborted();
9635
- buffered = await kernel.json({ op: "net-ws-send", handle });
9638
+ buffered = await send({});
9636
9639
  }
9637
9640
  },
9638
9641
  close: () => close(),