From 50d1db7d4cf45e48405d890bcce474c58bf2a4dd Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Wed, 26 Jun 2019 18:12:37 +0300 Subject: [PATCH] fix: debug android --start should allow to debug `tns debug android --start` should allow you to debug. However, immediately after opening the debug socket we set the cleanupService to clean the forwarded port once CLI process exits. As we have not set the cleanupService in long living mode, CLI calls injector.dispose and this cleans the debug socket. To handle this, just set the cleanupService in long living mode. --- lib/commands/debug.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/commands/debug.ts b/lib/commands/debug.ts index 30a2cfe5ab..3317b632df 100644 --- a/lib/commands/debug.ts +++ b/lib/commands/debug.ts @@ -12,6 +12,7 @@ export class DebugPlatformCommand extends ValidatePlatformCommandBase implements $projectData: IProjectData, $options: IOptions, $platformsDataService: IPlatformsDataService, + $cleanupService: ICleanupService, protected $logger: ILogger, protected $errors: IErrors, private $debugDataService: IDebugDataService, @@ -19,6 +20,7 @@ export class DebugPlatformCommand extends ValidatePlatformCommandBase implements private $liveSyncCommandHelper: ILiveSyncCommandHelper, private $androidBundleValidatorHelper: IAndroidBundleValidatorHelper) { super($options, $platformsDataService, $platformValidationService, $projectData); + $cleanupService.setShouldDispose(false); } public async execute(args: string[]): Promise { @@ -87,8 +89,7 @@ export class DebugIOSCommand implements ICommand { private $sysInfo: ISysInfo, private $projectData: IProjectData, $iosDeviceOperations: IIOSDeviceOperations, - $iOSSimulatorLogProvider: Mobile.IiOSSimulatorLogProvider, - $cleanupService: ICleanupService) { + $iOSSimulatorLogProvider: Mobile.IiOSSimulatorLogProvider) { this.$projectData.initializeProjectData(); // Do not dispose ios-device-lib, so the process will remain alive and the debug application (NativeScript Inspector or Chrome DevTools) will be able to connect to the socket. // In case we dispose ios-device-lib, the socket will be closed and the code will fail when the debug application tries to read/send data to device socket. @@ -96,7 +97,6 @@ export class DebugIOSCommand implements ICommand { // In case we do not set it to false, the dispose will be called once the command finishes its execution, which will prevent the debugging. $iosDeviceOperations.setShouldDispose(false); $iOSSimulatorLogProvider.setShouldDispose(false); - $cleanupService.setShouldDispose(false); } public execute(args: string[]): Promise {