fix: livesync should stop when all devices are disconnected #4478
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Whenever all devices/emulators/simulators that we are using for LiveSync operation are disconnected or we are unable to sync changes on them, the command (
tns debug,tns run...) should exit.This is not happening currently due to the setIntervals and iOS device detection that happens and does not stop when the devices are disconnected. So workaround the problem by handling the liveSyncStopped event for the livesync related commands. In case we receive liveSyncStopped for all devices that we've been using for LiveSync action, call process.exit. Use non-zero exit code for this case, as if we receive liveSyncStopped event, we've either received error for particular device or it has been stopped. For both cases this is not a correct behavior for LiveSync.
PR Checklist
What is the current behavior?
When you execute
tns run <platform>and disconnect all devices at some point, CLI command continue its execution.What is the new behavior?
When you execute
tns run <platform>and disconnect all devices at some point, CLI command stops its execution.Fixes issue #4495