Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add logs #628

Merged
merged 3 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions driver/lib/sessions/ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand All @@ -111,13 +114,15 @@ 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}`);
}

log.info(`Forwarding the remote port ${remotePort} to the local port ${localPort}`);

process.on(`beforeExit`, () => {
flutterDriver.localServer?.close();
flutterDriver.localServer = null;
});
return urlObject.toJSON();
};
2 changes: 1 addition & 1 deletion driver/lib/sessions/observatory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@

// 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);
Expand Down Expand Up @@ -183,14 +183,14 @@
isolateId: string|number
) {
log.debug(`>>> getIsolate`);
const isolate = await this.socket!.call(`getIsolate`, { isolateId: `${isolateId}` });

Check warning on line 186 in driver/lib/sessions/observatory.ts

View workflow job for this annotation

GitHub Actions / build (20)

Forbidden non-null assertion

Check warning on line 186 in driver/lib/sessions/observatory.ts

View workflow job for this annotation

GitHub Actions / build (18)

Forbidden non-null assertion

Check warning on line 186 in driver/lib/sessions/observatory.ts

View workflow job for this annotation

GitHub Actions / build (16)

Forbidden non-null assertion
log.debug(`<<< ${_.truncate(JSON.stringify(isolate), {'length': truncateLength})}`);
return isolate;
};

export const executeGetVMCommand = async function(this: FlutterDriver) {
log.debug(`>>> getVM`);
const vm = await this.socket!.call(`getVM`) as {

Check warning on line 193 in driver/lib/sessions/observatory.ts

View workflow job for this annotation

GitHub Actions / build (20)

Forbidden non-null assertion

Check warning on line 193 in driver/lib/sessions/observatory.ts

View workflow job for this annotation

GitHub Actions / build (18)

Forbidden non-null assertion

Check warning on line 193 in driver/lib/sessions/observatory.ts

View workflow job for this annotation

GitHub Actions / build (16)

Forbidden non-null assertion
isolates: [{
name: string,
id: number,
Expand All @@ -208,7 +208,7 @@
const elementObject = elementBase64 ? JSON.parse(decode(elementBase64)) : {};
const serializedCommand = { command, ...elementObject, ...extraArgs };
log.debug(`>>> ${JSON.stringify(serializedCommand)}`);
const data = await this.socket!.executeSocketCommand(serializedCommand);

Check warning on line 211 in driver/lib/sessions/observatory.ts

View workflow job for this annotation

GitHub Actions / build (20)

Forbidden non-null assertion

Check warning on line 211 in driver/lib/sessions/observatory.ts

View workflow job for this annotation

GitHub Actions / build (18)

Forbidden non-null assertion

Check warning on line 211 in driver/lib/sessions/observatory.ts

View workflow job for this annotation

GitHub Actions / build (16)

Forbidden non-null assertion
log.debug(`<<< ${JSON.stringify(data)} | previous command ${command}`);
if (data.isError) {
throw new Error(
Expand Down
Loading