Skip to content

Commit 4e7e815

Browse files
committed
Hook socket livesync with exit signals.
1 parent 23af849 commit 4e7e815

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

lib/services/livesync/android-device-livesync-sockets-service.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ export class AndroidDeviceSocketsLiveSyncService extends DeviceLiveSyncServiceBa
1515
protected $staticConfig: Config.IStaticConfig,
1616
private $logger: ILogger,
1717
protected device: Mobile.IAndroidDevice,
18-
private $options: ICommonOptions) {
18+
private $options: ICommonOptions,
19+
private $processService: IProcessService) {
1920
super($platformsData, device);
2021
this.livesyncTool = this.$injector.resolve(AndroidLivesyncTool);
22+
this.$processService.attachToProcessExitSignals(this.livesyncTool, this.livesyncTool.end);
2123
}
2224

2325
public async beforeLiveSyncAction(deviceAppData: Mobile.IDeviceAppData): Promise<void> {
@@ -35,7 +37,6 @@ export class AndroidDeviceSocketsLiveSyncService extends DeviceLiveSyncServiceBa
3537
const operationIdentifier = this.livesyncTool.generateOperationIdentifier();
3638
const doSyncPromise = this.livesyncTool.sendDoSyncOperation(operationIdentifier);
3739

38-
//TODO clear interval on exit sygnals/stopLivesync
3940
const syncInterval : NodeJS.Timer = setInterval(() => {
4041
if (this.livesyncTool.isOperationInProgress(operationIdentifier)) {
4142
this.$logger.info("Sync operation in progress...");
@@ -45,7 +46,10 @@ export class AndroidDeviceSocketsLiveSyncService extends DeviceLiveSyncServiceBa
4546
const clearSyncInterval = () => {
4647
clearInterval(syncInterval);
4748
};
49+
50+
this.$processService.attachToProcessExitSignals(this, clearSyncInterval);
4851
doSyncPromise.then(clearSyncInterval, clearSyncInterval);
52+
4953
await doSyncPromise;
5054

5155
if (!canExecuteFastSync) {

lib/services/livesync/android-livesync-library.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,9 @@ export class AndroidLivesyncTool implements IAndroidLivesyncTool {
201201
this.socketConnection.write(chunk);
202202
} else {
203203
const error = this.checkConnectionStatus();
204-
//TODO check if properly destroys stream
205-
//fileStream.destroy();
204+
//TODO Destroy method added in node 8.0.0.
205+
//when we depricate node 6.x uncoment the line belolw
206+
//fileStream.destroy(error);
206207
reject(error);
207208
}
208209
})

0 commit comments

Comments
 (0)