From 9b54fde9b69d68d05bfe018bc8752b2bbfce7abd Mon Sep 17 00:00:00 2001 From: Simon Chan <1330321+yume-chan@users.noreply.github.com> Date: Tue, 23 Jan 2024 22:36:42 +0800 Subject: [PATCH] fix(adb): fix AdbServerClient.waitFor returning immediately --- libraries/adb/src/server/client.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libraries/adb/src/server/client.ts b/libraries/adb/src/server/client.ts index 2694c3057..a3615a8a1 100644 --- a/libraries/adb/src/server/client.ts +++ b/libraries/adb/src/server/client.ts @@ -457,9 +457,12 @@ export class AdbServerClient { `wait-for-${type}-${state}`, ); - // `connect` resolves when server writes `OKAY`, - // but for this command the server writes `OKAY` after the condition is met. - await this.connect(service, options); + const socket = await this.connect(service, options); + const readable = new BufferedReadableStream(socket.readable); + await AdbServerClient.readOkay(readable); + + await readable.cancel(); + await socket.close(); } async createTransport(