diff --git a/lib/controllers/run-controller.ts b/lib/controllers/run-controller.ts index 290b9505d6..1237555a06 100644 --- a/lib/controllers/run-controller.ts +++ b/lib/controllers/run-controller.ts @@ -62,7 +62,7 @@ export class RunController extends EventEmitter implements IRunController { // so we cannot await it as this will cause infinite loop. const shouldAwaitPendingOperation = !stopOptions || stopOptions.shouldAwaitAllActions; - const deviceIdentifiersToRemove = deviceIdentifiers || _.map(liveSyncProcessInfo.deviceDescriptors, d => d.identifier); + const deviceIdentifiersToRemove = (deviceIdentifiers && deviceIdentifiers.length) ? deviceIdentifiers : _.map(liveSyncProcessInfo.deviceDescriptors, d => d.identifier); const removedDeviceIdentifiers = _.remove(liveSyncProcessInfo.deviceDescriptors, descriptor => _.includes(deviceIdentifiersToRemove, descriptor.identifier)) .map(descriptor => descriptor.identifier); diff --git a/test/controllers/run-controller.ts b/test/controllers/run-controller.ts index 9dc2e674da..e33fbc4688 100644 --- a/test/controllers/run-controller.ts +++ b/test/controllers/run-controller.ts @@ -240,6 +240,12 @@ describe("RunController", () => { currentDeviceIdentifiers: ["device1", "device2", "device3"], expectedDeviceIdentifiers: ["device1"], deviceIdentifiersToBeStopped: ["device1", "device4"] + }, + { + name: "stops LiveSync operation for all devices when stop method is called with empty array", + currentDeviceIdentifiers: ["device1", "device2", "device3"], + expectedDeviceIdentifiers: ["device1", "device2", "device3"], + deviceIdentifiersToBeStopped: [] } ];