Skip to content

Commit 84a5a0c

Browse files
committed
fix: fix stop livesync when the method is called with empty array
Currently when stop method is called with empty array, the livesync process is stopped for all devices but the runOnDeviceStopped event is not emitted. This PR fixes this behavior as ensures the runOnDeviceStopped event will be emitted for all connected devices.
1 parent 3cabd7e commit 84a5a0c

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/controllers/run-controller.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class RunController extends EventEmitter implements IRunController {
6262
// so we cannot await it as this will cause infinite loop.
6363
const shouldAwaitPendingOperation = !stopOptions || stopOptions.shouldAwaitAllActions;
6464

65-
const deviceIdentifiersToRemove = deviceIdentifiers || _.map(liveSyncProcessInfo.deviceDescriptors, d => d.identifier);
65+
const deviceIdentifiersToRemove = (deviceIdentifiers && deviceIdentifiers.length) ? deviceIdentifiers : _.map(liveSyncProcessInfo.deviceDescriptors, d => d.identifier);
6666

6767
const removedDeviceIdentifiers = _.remove(liveSyncProcessInfo.deviceDescriptors, descriptor => _.includes(deviceIdentifiersToRemove, descriptor.identifier))
6868
.map(descriptor => descriptor.identifier);

test/controllers/run-controller.ts

+6
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,12 @@ describe("RunController", () => {
240240
currentDeviceIdentifiers: ["device1", "device2", "device3"],
241241
expectedDeviceIdentifiers: ["device1"],
242242
deviceIdentifiersToBeStopped: ["device1", "device4"]
243+
},
244+
{
245+
name: "stops LiveSync operation for all devices when stop method is called with empty array",
246+
currentDeviceIdentifiers: ["device1", "device2", "device3"],
247+
expectedDeviceIdentifiers: ["device1", "device2", "device3"],
248+
deviceIdentifiersToBeStopped: []
243249
}
244250
];
245251

0 commit comments

Comments
 (0)