Skip to content

Fix recursive calling of actions. #2976

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 13, 2017
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion lib/definitions/livesync.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,10 @@ interface ILiveSyncService {
* Stops LiveSync operation for specified directory.
* @param {string} projectDir The directory for which to stop the operation.
* @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.
* @param { shouldAwaitAllActions: boolean } @optional stopOptions Specifies whether we should await all actions.
* @returns {Promise<void>}
*/
stopLiveSync(projectDir: string, deviceIdentifiers?: string[]): Promise<void>;
stopLiveSync(projectDir: string, deviceIdentifiers?: string[], stopOptions?: { shouldAwaitAllActions: boolean }): Promise<void>;
}

/**
Expand Down
10 changes: 5 additions & 5 deletions lib/services/livesync/livesync-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class LiveSyncService extends EventEmitter implements ILiveSyncService {
await this.liveSyncOperation(deviceDescriptors, liveSyncData, projectData);
}

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

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

liveSyncProcessInfo.watcherInfo = null;

if (liveSyncProcessInfo.actionsChain) {
if (liveSyncProcessInfo.actionsChain && (!stopOptions || stopOptions.shouldAwaitAllActions)) {
await liveSyncProcessInfo.actionsChain;
}

Expand Down Expand Up @@ -127,7 +127,7 @@ export class LiveSyncService extends EventEmitter implements ILiveSyncService {

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

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

Expand Down Expand Up @@ -250,7 +250,7 @@ export class LiveSyncService extends EventEmitter implements ILiveSyncService {
applicationIdentifier: projectData.projectId
});

await this.stopLiveSync(projectData.projectDir, [device.deviceInfo.identifier]);
await this.stopLiveSync(projectData.projectDir, [device.deviceInfo.identifier], { shouldAwaitAllActions: false });
}
};

Expand Down Expand Up @@ -360,7 +360,7 @@ export class LiveSyncService extends EventEmitter implements ILiveSyncService {
applicationIdentifier: projectData.projectId
});

await this.stopLiveSync(projectData.projectDir, [deviceError.deviceIdentifier]);
await this.stopLiveSync(projectData.projectDir, [deviceError.deviceIdentifier], { shouldAwaitAllActions: false });
}
}
}
Expand Down