From 98878bd81231a631c494b6767576097f945eb813 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Thu, 14 Jan 2021 20:32:27 -0800 Subject: refactor: IO resource types, fix concurrent read/write and graceful close (#9118) Fixes: 9032. --- std/http/_mock_conn.ts | 4 +++- std/ws/test.ts | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'std') diff --git a/std/http/_mock_conn.ts b/std/http/_mock_conn.ts index b2abb301a..8f3396dbd 100644 --- a/std/http/_mock_conn.ts +++ b/std/http/_mock_conn.ts @@ -14,7 +14,9 @@ export function mockConn(base: Partial = {}): Deno.Conn { port: 0, }, rid: -1, - closeWrite: (): void => {}, + closeWrite: (): Promise => { + return Promise.resolve(); + }, read: (): Promise => { return Promise.resolve(0); }, diff --git a/std/ws/test.ts b/std/ws/test.ts index 45e34d579..c437d8c28 100644 --- a/std/ws/test.ts +++ b/std/ws/test.ts @@ -102,7 +102,7 @@ Deno.test("[ws] read unmasked ping / pong frame", async () => { ); assertEquals(actual1, "Hello"); // deno-fmt-ignore - const pongFrame= [0x8a, 0x85, 0x37, 0xfa, 0x21, 0x3d, 0x7f, 0x9f, 0x4d, 0x51, 0x58] + const pongFrame = [0x8a, 0x85, 0x37, 0xfa, 0x21, 0x3d, 0x7f, 0x9f, 0x4d, 0x51, 0x58] const buf2 = new BufReader(new Deno.Buffer(new Uint8Array(pongFrame))); const pong = await readFrame(buf2); assertEquals(pong.opcode, OpCode.Pong); @@ -283,7 +283,7 @@ Deno.test("[ws] ws.close() should use 1000 as close code", async () => { function dummyConn(r: Deno.Reader, w: Deno.Writer): Deno.Conn { return { rid: -1, - closeWrite: (): void => {}, + closeWrite: (): Promise => Promise.resolve(), read: (x: Uint8Array): Promise => r.read(x), write: (x: Uint8Array): Promise => w.write(x), close: (): void => {}, -- cgit v1.2.3