Skip to content

fix: initial sync on Preview app (Android) leads to loop #3963

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
Oct 1, 2018

Conversation

rosen-vladimirov
Copy link
Contributor

When tns preview command is executed and the QR code is scanned with Android device, the Preview app on this device asks for initial sync of the files. At this point CLI starts preparing the project and once the files are prepared, it sends them to device.
However, this operation may take some time, especially for code sharing projects, which have a lot of dependencies and webpack is used. Meanwhile the Preview app on device sees that it had not received the files within 10 seconds and sends a new message to get the initial files.
So CLI starts another process of preparation and trying to sync the changes. Based on the time required, this may become an indefinite loop.
Fix this by caching the promise for initial sync and in case device asks again, CLI will use the already pending promise.

Also fix the case where another device from the same platform is used to scan the QR code at some point. Currently we've not passed device identifier to pubnub and the initial sync was sending the files to all devices in the mentioned scenario.

PR Checklist

What is the current behavior?

When trying to execute tns preview --bundle for this app on a slower Hard Drive, the operation takes more than 10 seconds to prepare the project and LiveSync to Preview app creates an indefinite loop of preparation and syncing.

What is the new behavior?

The app can be synced.

When `tns preview` command is executed and the QR code is scanned with Android device, the Preview app on this device asks for initial sync of the files. At this point CLI starts preparing the project and once the files are prepared, it sends them to device.
However, this operation may take some time, especially for code sharing projects, which have a lot of dependencies and webpack is used. Meanwhile the Preview app on device sees that it had not received the files within 10 seconds and sends a new message to get the initial files.
So CLI starts another process of preparation and trying to sync the changes. Based on the time required, this may become an indefinite loop.
Fix this by caching the promise for initial sync and in case device asks again, CLI will use the already pending promise.

Also fix the case where another device from the same platform is used to scan the QR code at some point. Currently we've not passed device identifier to pubnub and the initial sync was sending the files to all devices in the mentioned scenario.
@rosen-vladimirov rosen-vladimirov added this to the 5.0.0 milestone Oct 1, 2018
@rosen-vladimirov rosen-vladimirov self-assigned this Oct 1, 2018
@rosen-vladimirov rosen-vladimirov merged commit 5c3f893 into master Oct 1, 2018
@rosen-vladimirov rosen-vladimirov deleted the vladimirov/fix-inital-sync-playground branch October 1, 2018 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants