···11-import { type ServerOptions, WebSocketServer } from "ws";
11+import { type ServerOptions, type WebSocket, WebSocketServer } from "ws";
22import { ErrorFrame, type Frame } from "./frames.ts";
33import { logger } from "../logger.ts";
44import { CloseCode, DisconnectError } from "./types.ts";
+7
xrpc-server/tests/stream_test.ts
···77 MessageFrame,
88 XrpcStreamServer,
99} from "../mod.ts";
1010+import { WebSocket } from "ws";
1011import { assertEquals, assertInstanceOf } from "@std/assert";
11121213const wait = (ms: number) => new Promise((res) => setTimeout(res, ms));
···187188 error = err;
188189 }
189190191191+ // Wait for the close event in case the socket is still in CLOSING (2) state
192192+ if (ws.readyState !== ws.CLOSED) {
193193+ await new Promise<void>((resolve) => {
194194+ ws.onclose = () => resolve();
195195+ });
196196+ }
190197 assertEquals(ws.readyState, ws.CLOSED);
191198 assertEquals(frames.length, 2);
192199 assertEquals(frames, [new MessageFrame(1), new MessageFrame(2)]);