From 3474c2ed452e9581bbccfd5911d4ca0ef85c5f81 Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Fri, 24 Nov 2023 10:27:16 -0800 Subject: [PATCH 1/3] add logs --- driver/lib/sessions/ios.ts | 5 +++++ driver/lib/sessions/observatory.ts | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/driver/lib/sessions/ios.ts b/driver/lib/sessions/ios.ts index 523fc220..405c48f4 100644 --- a/driver/lib/sessions/ios.ts +++ b/driver/lib/sessions/ios.ts @@ -95,11 +95,14 @@ export const getObservatoryWsUri = async ( destroyCommChannel(); localSocket.destroy(); }); + remoteSocket.on('error', (e) => log.debug(e)); + localSocket.once(`end`, destroyCommChannel); localSocket.once(`close`, () => { destroyCommChannel(); remoteSocket.destroy(); }); + localSocket.on('error', (e) => log.warn(e.message)); localSocket.pipe(remoteSocket); remoteSocket.pipe(localSocket); }); @@ -111,6 +114,7 @@ export const getObservatoryWsUri = async ( try { await listeningPromise; } catch (e) { + flutterDriver.localServer = null; throw new Error(`Cannot listen on the local port ${localPort}. Original error: ${e.message}`); } @@ -118,6 +122,7 @@ export const getObservatoryWsUri = async ( process.on(`beforeExit`, () => { flutterDriver.localServer?.close(); + flutterDriver.localServer = null; }); return urlObject.toJSON(); }; diff --git a/driver/lib/sessions/observatory.ts b/driver/lib/sessions/observatory.ts index fa9706d9..a7a81e00 100644 --- a/driver/lib/sessions/observatory.ts +++ b/driver/lib/sessions/observatory.ts @@ -227,7 +227,9 @@ export const fetchObservatoryUrl = (deviceLogs: [{ message: string }]): URL => { break; } } - if (!dartObservatoryURL) { + if (dartObservatoryURL) { + log.info(`${dartObservatoryURL.href} was found.`); + } else { throw new Error(`No observatory URL matching to '${OBSERVATORY_URL_PATTERN}' was found in the device log. ` + `Please make sure the application under test is configured properly according to ` + `https://github.com/appium-userland/appium-flutter-driver#usage and that it does not crash on startup.`); From b346734d7c092255fbfa0c862e5cc61cd139c05c Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Fri, 24 Nov 2023 10:32:49 -0800 Subject: [PATCH 2/3] remove --- driver/lib/sessions/observatory.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/driver/lib/sessions/observatory.ts b/driver/lib/sessions/observatory.ts index a7a81e00..fa9706d9 100644 --- a/driver/lib/sessions/observatory.ts +++ b/driver/lib/sessions/observatory.ts @@ -227,9 +227,7 @@ export const fetchObservatoryUrl = (deviceLogs: [{ message: string }]): URL => { break; } } - if (dartObservatoryURL) { - log.info(`${dartObservatoryURL.href} was found.`); - } else { + if (!dartObservatoryURL) { throw new Error(`No observatory URL matching to '${OBSERVATORY_URL_PATTERN}' was found in the device log. ` + `Please make sure the application under test is configured properly according to ` + `https://github.com/appium-userland/appium-flutter-driver#usage and that it does not crash on startup.`); From f69d656ca0cf4883b79b394d30ba3bf154793c34 Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Fri, 24 Nov 2023 10:40:42 -0800 Subject: [PATCH 3/3] add error msg --- driver/lib/sessions/observatory.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/driver/lib/sessions/observatory.ts b/driver/lib/sessions/observatory.ts index fa9706d9..7b83316d 100644 --- a/driver/lib/sessions/observatory.ts +++ b/driver/lib/sessions/observatory.ts @@ -72,7 +72,7 @@ export const connectSocket = async ( // Add an 'error' event handler for the client socket const onErrorListener = (ex: Error) => { - log.error(JSON.stringify(ex)); + log.error(`Connection to ${dartObservatoryURL} got an error: ${ex.message}`); removeListenerAndResolve(null); }; socket.on(`error`, onErrorListener);