I'm using Atom with the atom-typescript package to edit the sample-Groceries folder. I'm on a Windows 10 machine and I'm trying to run tns livesync android --emulator --watch, which works fine. Emulator comes up and running, displays the front page of the app. I'm even able to change change the files a few times and see the emulator reload the page.
Here is what my command line looks like, with a successful change, then error:
JS: Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.
10:41:03 AM - File change detected. Starting incremental compilation...
10:41:04 AM - Compilation complete. Watching for file changes.
Executing before-prepare hook from C:\Users\gibry\Documents\Sandbox\NativeScript\sample-Groceries\hooks\before-prepare\nativescript-dev-typescript.js
Project successfully prepared (android)
Transferring project files...
Successfully transferred all files.
Applying changes...
Successfully synced application org.nativescript.groceries on device emulator-5554.
JS: Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.
10:41:12 AM - File change detected. Starting incremental compilation...
Error: read ECONNRESET
at exports._errnoException (util.js:1036:11)
at TCP.onread (net.js:564:26)
Sending exception report (press Ctrl+C to stop)...
Any ideas to what can cause a connection reset, after several successful cycles of livesyncing? Also, where can I find the exception report mentioned in the last line?
Update: I ran tns doctor and got no errors. I turned on usage-reporting and error-reporting and the instance I ran after that lasted a long time without interruption. When I ended that and started up a new one, the new instance ended within a few minutes. I'm thinking this may be an issue with running commands too quickly after each other, but I'll keep updating this as I work.
@gbhojraj thanks for reporting this issue. I can confirm this is an actual problem as it occurred for me as well today.
Update: This happened to me again OUTSIDE livesync. I ran tns run android --emulator and I received the same ECONNRESET error after about 2 minutes of using it. I was working on Chapter 3 of the tutorial. I'm using the default emulator in the avd.
A similar issue regarding the same error was referenced in this Nativescript repo issue and was supposedly fixed in 2.4.0, but that is the version I am running. I also have tns-android at 2.4.1.
Here are the results of my log trace:
Successfully deployed on device with identifier 'emulator-5554'.
spawn: C:\Users\gibry\AppData\Local\Android\android-sdk\platform-tools\adb "-s" "emulator-5554" "shell" "monkey" "-p" "org.nativescript.groceries" "-c" "android.intent.category.LAUNCHER" "1"
Result when throw error is false:
{ stdout: 'Events injected: 1\r\r\n## Network stats: elapsed time=14ms (0ms mobile, 0ms wifi, 14ms not connected)\r\r\n',
stderr: '',
exitCode: 0 }
spawn: C:\Users\gibry\AppData\Local\Android\android-sdk\platform-tools\adb "-s" "emulator-5554" "logcat" "-c"
Result when throw error is false:
{ stdout: '', stderr: '', exitCode: 0 }
spawn: C:\Users\gibry\AppData\Local\Android\android-sdk\platform-tools\adb "-s" "emulator-5554" "logcat"
JS: Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.
Error: read ECONNRESET
at exports._errnoException (util.js:1036:11)
at TCP.onread (net.js:564:26)
Analytics statuses:
{ TrackFeatureUsage: 0, TrackExceptions: 0 }
Trying to track exception with message 'read ECONNRESET'.
Waiting for analytics to send information. Will check in a 1000ms.
@gbhojraj a fix is now available in the master branch, and should soon be available in npm with the @next tag.
Please let us know if things work as expected after updating the nativescript CLI!
Still having the issue after updating and restarting my cmd with [email protected]
Do you see an error activity loaded inside the app before this console error is displayed?
No. Here is what my cmd looks like:
C:\Users\gibry\Documents\Sandbox\NativeScript\sample-Groceries>tns livesync android --watch
Executing before-prepare hook from C:\Users\gibry\Documents\Sandbox\NativeScript\sample-Groceries\hooks\before-prepare\nativescript-dev-typescript.js
Found peer TypeScript 2.1.1
Project successfully prepared (android)
Executing before-livesync hook from C:\Users\gibry\Documents\Sandbox\NativeScript\sample-Groceries\hooks\before-livesync\nativescript-angular-sync.js
Starting Android emulator with image Emulator-Api23-Default
Waiting for emulator device initialization....
Transferring project files...
Successfully transferred all files.
Applying changes...
Successfully synced application org.nativescript.groceries on device emulator-5554.
Executing before-watch hook from C:\Users\gibry\Documents\Sandbox\NativeScript\sample-Groceries\hooks\before-watch\nativescript-dev-typescript.js
Found peer TypeScript 2.1.1
JS: Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.
1:26:21 PM - Compilation complete. Watching for file changes.
Error: read ECONNRESET
at exports._errnoException (util.js:1036:11)
at TCP.onread (net.js:564:26)
Sending exception report (press Ctrl+C to stop)...
C:\Users\gibry\Documents\Sandbox\NativeScript\sample-Groceries>tns --version
2.5.0-2016-11-30-7269
I'm running the sample groceries app, currently at chapter 3. I don't have to interact with the emulator at all for this error to be thrown.
This file is in ~/platforms/android/build/outputs/logs, so I think it's a log file from my last run. Don't know if it provides any useful information about the ending.
Here is my attempt at using adb logcat to catch potential errors. There was at least one error early in running the emulator, but no high priority messages near the end when tns crashed.
tns-debug.txt
@vchimev @tzraikov - can you please check this?
@gbhojraj thanks for providing logs, but these should be unrelated to the issue at hand. One outputs result of merging assets and the other is, well, android log with runtime debug output.
We'll investigate further, thanks for your patience!
@gbhojraj Thank you for those details. The ECONNRESET message appears when the server side (the app in the android simulator In this case) closes the TCP conversation abruptly. This could happen when it crashes for some reason. We are still trying to reproduce this issue. Please, could you remove the app from the simulator and try to livesync again? If the issue still reproduces, you could help by sending us the broken project (including the platforms folder).
Thanks @Pip3r4o for the explanation of the files. When the CLI crashes on ECONNRESET, the last line is Sending exception report (press Ctrl+C to stop)... and I was trying to find that.
@tzraikov Do you mean I should run the simulator first from android avd and then run the livesync command? Or that I should create a new blank project and try to run it?
Also, the project I'm using is clones from Nativescript/sample-Groceries. The only difference between my code and theirs is in the /app folder, where I sometimes use es6 syntax. I didn't mess around with any other files.
Follow those steps:
android avdtns livesync android --watch@gbhojraj Please note that if your app contains errors, you will see the error screen on the simulator. However, the CLI should be functional and it will sync all changes in your code.
Thanks @tzraikov . I'm still getting the error. I've seen errors on the simulator before, but not in connection with ECONNRESET. I've seen no errors regarding that.
I'm still getting the error, even if I wipe user data (and the app) from the emulator. I've pushed this project to a new repo: https://github.com/gbhojraj/sample-Groceries
@gbhojraj I tested the project from your repo. After commenting some lines of code it compiles and the livesync works as expected. It is very strange that you experience this kind of error, our @next version contains the following code which filters such messages:
https://github.com/NativeScript/nativescript-cli/blob/master/lib/services/livesync/android-device-livesync-service.ts#L112
Could you post again the exact message that you get? I want to be sure that we are talking about the same issue.
In some scenarios npm on Windows caches its packages and that is why I suggest the following:
npm uninstall -g nativescriptnpm cache cleannpm install -g nativescripttns run android --emulatortns livesync android --emulator --watchAfter following the steps you outlined, I tried running the project again. It seemed like it was working, but after a few trials (stopping tns and running it again), I started seeing the error again. I'll attach a TXT with the full output of my command, but here's the error specifically:
Error: read ECONNRESET
at exports._errnoException (util.js:1036:11)
at TCP.onread (net.js:564:26)
Sending exception report (press Ctrl+C to stop)...
C:\Users\gibry\Documents\Sandbox\NativeScript\sample-Groceries>
My problem isn't that livesync isn't restarting on malformed code. It's that both tns run and tns livesync sometimes randomly throw ECONNRESET errors even without input from me, whether that's changing the code or clicking an empty button on the emulator. And when livesync throws this error, it stops the livesync process completely. After the error is thrown and tns disconnects, the project is still viewable and usable in the emulator.
I didn't think it would be a problem with the project, because it's just a sample project. I'll try running another sample project. But I don't know what on my system could be interfering with the connection between the CLI and AVD.
(Sorry, just realizedd I didn't attach the cmd output before)
tns-run.txt
Update: It seems if I launch the emulator from android avd and then connect with tns livesync android --watch after it's fully loaded, I don't have any connection issues.
@gbhojraj Thanks for this information. We observed issues with some versions of the latest android emulators. Please, could you upgrade your Android SDK and emulators to the latest version. If this doesn't help, send us your project in a broken state (including the platforms folder). This will help us to investigate further.
gbhojraj - thanks! Had exactly the same issue even with the basic HelloWorld project and the workaround you suggested worked for me (launch the emulator from android avd and then connect with tns livesync android --watch).
Same error here and same solution.
Start android emulator with android avd selecting the one created by the NativeScript install (I have more emulators) and start the project with tns run android --watch.
also, same error and same solution. thanks
Thanks @gbhojraj for continuing pursuit to solve this issue.
Thanks @tzraikov .
Had this same issue and trying to get over this for quite some time and did same steps to resolve issue.
Just need to know one thing though.. Can we make full fledged e-commerce app on this platform or more work needs to be done to make this platform to use on commercial basis for non-stopping development.
Almost a year later and..
Same problem, same solution described by @gbhojraj
Most helpful comment
Update: It seems if I launch the emulator from
android avdand then connect withtns livesync android --watchafter it's fully loaded, I don't have any connection issues.