Skip to content

Commit 50d1db7

Browse files
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.
1 parent 671f33d commit 50d1db7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/commands/debug.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ export class DebugPlatformCommand extends ValidatePlatformCommandBase implements
1212
$projectData: IProjectData,
1313
$options: IOptions,
1414
$platformsDataService: IPlatformsDataService,
15+
$cleanupService: ICleanupService,
1516
protected $logger: ILogger,
1617
protected $errors: IErrors,
1718
private $debugDataService: IDebugDataService,
1819
private $debugController: IDebugController,
1920
private $liveSyncCommandHelper: ILiveSyncCommandHelper,
2021
private $androidBundleValidatorHelper: IAndroidBundleValidatorHelper) {
2122
super($options, $platformsDataService, $platformValidationService, $projectData);
23+
$cleanupService.setShouldDispose(false);
2224
}
2325

2426
public async execute(args: string[]): Promise<void> {
@@ -87,16 +89,14 @@ export class DebugIOSCommand implements ICommand {
8789
private $sysInfo: ISysInfo,
8890
private $projectData: IProjectData,
8991
$iosDeviceOperations: IIOSDeviceOperations,
90-
$iOSSimulatorLogProvider: Mobile.IiOSSimulatorLogProvider,
91-
$cleanupService: ICleanupService) {
92+
$iOSSimulatorLogProvider: Mobile.IiOSSimulatorLogProvider) {
9293
this.$projectData.initializeProjectData();
9394
// 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.
9495
// 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.
9596
// That's why the `$ tns debug ios --justlaunch` command will not release the terminal.
9697
// 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.
9798
$iosDeviceOperations.setShouldDispose(false);
9899
$iOSSimulatorLogProvider.setShouldDispose(false);
99-
$cleanupService.setShouldDispose(false);
100100
}
101101

102102
public execute(args: string[]): Promise<void> {

0 commit comments

Comments
 (0)