Skip to content

Commit 17e6611

Browse files
authored
Fix recursive calling of actions. (#2976)
1 parent 98db3bd commit 17e6611

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

lib/definitions/livesync.d.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,10 @@ interface ILiveSyncService {
160160
* Stops LiveSync operation for specified directory.
161161
* @param {string} projectDir The directory for which to stop the operation.
162162
* @param {string[]} @optional deviceIdentifiers Device ids for which to stop the application. In case nothing is passed, LiveSync operation will be stopped for all devices.
163+
* @param { shouldAwaitAllActions: boolean } @optional stopOptions Specifies whether we should await all actions.
163164
* @returns {Promise<void>}
164165
*/
165-
stopLiveSync(projectDir: string, deviceIdentifiers?: string[]): Promise<void>;
166+
stopLiveSync(projectDir: string, deviceIdentifiers?: string[], stopOptions?: { shouldAwaitAllActions: boolean }): Promise<void>;
166167
}
167168

168169
/**

lib/services/livesync/livesync-service.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class LiveSyncService extends EventEmitter implements ILiveSyncService {
4040
await this.liveSyncOperation(deviceDescriptors, liveSyncData, projectData);
4141
}
4242

43-
public async stopLiveSync(projectDir: string, deviceIdentifiers?: string[]): Promise<void> {
43+
public async stopLiveSync(projectDir: string, deviceIdentifiers?: string[], stopOptions?: { shouldAwaitAllActions: boolean }): Promise<void> {
4444
const liveSyncProcessInfo = this.liveSyncProcessesInfo[projectDir];
4545

4646
if (liveSyncProcessInfo) {
@@ -67,7 +67,7 @@ export class LiveSyncService extends EventEmitter implements ILiveSyncService {
6767

6868
liveSyncProcessInfo.watcherInfo = null;
6969

70-
if (liveSyncProcessInfo.actionsChain) {
70+
if (liveSyncProcessInfo.actionsChain && (!stopOptions || stopOptions.shouldAwaitAllActions)) {
7171
await liveSyncProcessInfo.actionsChain;
7272
}
7373

@@ -127,7 +127,7 @@ export class LiveSyncService extends EventEmitter implements ILiveSyncService {
127127

128128
await this.initialSync(projectData, deviceDescriptorsForInitialSync, liveSyncData);
129129

130-
if (!liveSyncData.skipWatcher && deviceDescriptors && deviceDescriptors.length) {
130+
if (!liveSyncData.skipWatcher && this.liveSyncProcessesInfo[projectData.projectDir].deviceDescriptors.length) {
131131
// Should be set after prepare
132132
this.$injector.resolve<DeprecatedUsbLiveSyncService>("usbLiveSyncService").isInitialized = true;
133133

@@ -250,7 +250,7 @@ export class LiveSyncService extends EventEmitter implements ILiveSyncService {
250250
applicationIdentifier: projectData.projectId
251251
});
252252

253-
await this.stopLiveSync(projectData.projectDir, [device.deviceInfo.identifier]);
253+
await this.stopLiveSync(projectData.projectDir, [device.deviceInfo.identifier], { shouldAwaitAllActions: false });
254254
}
255255
};
256256

@@ -360,7 +360,7 @@ export class LiveSyncService extends EventEmitter implements ILiveSyncService {
360360
applicationIdentifier: projectData.projectId
361361
});
362362

363-
await this.stopLiveSync(projectData.projectDir, [deviceError.deviceIdentifier]);
363+
await this.stopLiveSync(projectData.projectDir, [deviceError.deviceIdentifier], { shouldAwaitAllActions: false });
364364
}
365365
}
366366
}

0 commit comments

Comments
 (0)