Skip to content
Merged
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
13 changes: 10 additions & 3 deletions lib/common/mobile/android/android-emulator-services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getCurrentEpochTime, sleep } from "../../helpers";
import { EOL } from "os";
import * as _ from "lodash";
import { LoggerConfigData } from "../../../constants";
import { IChildProcess, IUtils } from "../../declarations";
import { IChildProcess, IUserSettingsService, IUtils } from "../../declarations";
import { injector } from "../../yok";
import * as semver from "semver";

Expand All @@ -18,6 +18,7 @@ export class AndroidEmulatorServices
private $emulatorHelper: Mobile.IEmulatorHelper,
private $logger: ILogger,
private $utils: IUtils,
private $userSettingsService: IUserSettingsService,
) {}

public async getEmulatorImages(): Promise<Mobile.IEmulatorImagesOutput> {
Expand Down Expand Up @@ -154,7 +155,7 @@ export class AndroidEmulatorServices
};
}

this.spawnEmulator(emulator);
await this.spawnEmulator(emulator);

const isInfiniteWait = this.$utils.getMilliSecondsTimeout(timeout) === 0;
let hasTimeLeft = getCurrentEpochTime() < endTimeEpoch;
Expand Down Expand Up @@ -186,7 +187,7 @@ export class AndroidEmulatorServices
}
}

private spawnEmulator(emulator: Mobile.IDeviceInfo): void {
private async spawnEmulator(emulator: Mobile.IDeviceInfo) {
let pathToEmulatorExecutable = null;
let startEmulatorArgs = null;
if (emulator.vendor === AndroidVirtualDevice.AVD_VENDOR_NAME) {
Expand All @@ -195,6 +196,12 @@ export class AndroidEmulatorServices
startEmulatorArgs = this.$androidVirtualDeviceService.startEmulatorArgs(
emulator.imageIdentifier,
);
try {
const additionalArgs = await this.$userSettingsService.getSettingValue<string[]>("androidEmulatorStartArgs");
if (additionalArgs?.length) {
startEmulatorArgs.push(...additionalArgs);
}
} catch (error) {}
Comment on lines +199 to +204
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -nP -C3 'interface\s+IUserSettingsService' --type=ts
ast-grep --pattern 'getSettingValue<$_>($_): $_'

Repository: NativeScript/nativescript-cli

Length of output: 464


Don’t silently swallow settings/emulator-args read errors; log at trace level.

The empty catch around androidEmulatorStartArgs retrieval (and startEmulatorArgs.push(...)) discards any failures, making misconfiguration hard to diagnose while keeping the non-fatal behavior.

♻️ Proposed change
 			try {
 				const additionalArgs = await this.$userSettingsService.getSettingValue<string[]>("androidEmulatorStartArgs");
 				if (additionalArgs?.length) {
 					startEmulatorArgs.push(...additionalArgs);
 				}
-			} catch (error) {}
+			} catch (error) {
+				this.$logger.trace(
+					`Failed to read 'androidEmulatorStartArgs' setting. More info: ${error}`,
+				);
+			}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
try {
const additionalArgs = await this.$userSettingsService.getSettingValue<string[]>("androidEmulatorStartArgs");
if (additionalArgs?.length) {
startEmulatorArgs.push(...additionalArgs);
}
} catch (error) {}
try {
const additionalArgs = await this.$userSettingsService.getSettingValue<string[]>("androidEmulatorStartArgs");
if (additionalArgs?.length) {
startEmulatorArgs.push(...additionalArgs);
}
} catch (error) {
this.$logger.trace(
`Failed to read 'androidEmulatorStartArgs' setting. More info: ${error}`,
);
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/common/mobile/android/android-emulator-services.ts` around lines 199 -
204, The try/catch around reading androidEmulatorStartArgs silently swallows
errors; modify the block that calls
this.$userSettingsService.getSettingValue<string[]>("androidEmulatorStartArgs")
(and the subsequent startEmulatorArgs.push(...additionalArgs)) to catch errors
but log them at trace level instead of ignoring them: use the service's logger
(e.g. this.$logger.trace or equivalent) to record the caught error with context
("reading androidEmulatorStartArgs") and then continue to preserve the non-fatal
behavior.

} else if (
emulator.vendor === AndroidVirtualDevice.GENYMOTION_VENDOR_NAME
) {
Expand Down
Loading