Skip to content
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

Livesync error with webstorm temporary files (3.0.0-rc.1) #2720

Closed
daveware-nv opened this issue Apr 19, 2017 · 12 comments
Closed

Livesync error with webstorm temporary files (3.0.0-rc.1) #2720

daveware-nv opened this issue Apr 19, 2017 · 12 comments
Milestone

Comments

@daveware-nv
Copy link

Did you verify this is a real problem by searching Stack Overflow and the other open issues in this repo?

I have searched, but the results seem to refer to the old occurrence of this bug (this problem or something similar was also present in 2.5.0, but went away when I switched to 2.5.2).

Tell us about the problem

The temporary editor files in Jetbrains based IDEs seem to confuse the livesync, so when I save a file while using tns run android --emulator I get errors like:

Unable to sync files. Error is: Multiple errors were thrown:
ENOENT: no such file or directory, stat '/scratch/platforms/android/src/main/assets/app/app.module.ts___jb_tmp___'

I believe the process they use for saving is something like:

  • Save to temporary file
  • Delete original
  • Rename temporary over original

Which platform(s) does your issue occur on?

Android (probably both)

Please provide the following version numbers that your issue occurs with:

  • CLI: 3.0.0-rc.1
  • Cross-platform modules: 3.0.0-rc.2
  • Runtime(s):
"tns-android": {
      "version": "3.0.0-rc.1"
    }

Please tell us how to recreate the issue in as much detail as possible.

  • Create a new angular project using tns create
  • Start the livesync tns run android --emulator
  • modify and save app/app.module.ts (or any other file really) file using webstorm (I'm currently using Webstorm 2017.1.1 on Ubuntu Linux 16.04)
@dtopuzov dtopuzov added this to the 3.1.0 milestone May 3, 2017
@CanKattwinkel
Copy link

Really annoying! My workflow has almost come to standstill. Affects me with Ubuntu and IntelliJ. Please fix!

@fvonberg
Copy link

fvonberg commented May 4, 2017

I got the same problem :-( It worked in older IntelliJ/NativeScript Versions for me.

@straussCS
Copy link

Same for me here, LifeSync not usable with Intellij IDEA

@echap
Copy link

echap commented May 11, 2017

Same here, with the 3.0.0 cli ! (Ubuntu/webstorm)

@jbsouvestre
Copy link

I'm having the same issue but you can workaround that by disabling "safe write" in Intellij:

tooltip_710

(Tested in Webstorm)

@dtopuzov
Copy link
Contributor

dtopuzov commented May 12, 2017

@jbsouvestre @echap @straussCS @fvonberg @CanKattwinkel @daveware-nv
Can you reproduce the issue on macOS or Windows?

Since I have no WebStorm I simulate it with script:

sed s/Stegen/Unknown/g item.service.ts > item.service.ts____tmp___ 
rm -rf item.service.ts
mv item.service.ts____tmp___ item.service.ts

and can not reproduce on macOS Sierra.

@CanKattwinkel
Copy link

@dtopuzov sorry only Ubuntu available. You could try with free version of IntelliJ/Webstorm

@yyosifov
Copy link
Contributor

yyosifov commented May 12, 2017

@dtopuzov Based on your script I've just added more pressure like this:

for i in {1..100}; do
    sed s/Stegen/Unknown/g item.service.ts > item.service.ts____tmp___;
    rm -rf item.service.ts;
    mv item.service.ts____tmp___ item.service.ts;
done

and I can reproduce it this way. Will try to fix it now.

@yyosifov yyosifov self-assigned this May 16, 2017
@yyosifov
Copy link
Contributor

@jbsouvestre @echap @straussCS @fvonberg @CanKattwinkel @daveware-nv
We have a quick fix for this issue. The library we use for watching the directory to know when new files are created supports mechanism to handle cases like this where there are instantly created and then deleted files.

Can you give it a try and give feedback:

  1. Locate where your local nativescript installation is:
which tns     # Result is like /usr/local/bin/tns
ls -la /usr/local/bin/tns  # Result is like /usr/local/bin/tns -> ../lib/node_modules/nativescript/bin/tns
  1. Go to your local nativescript installation folder in the livesync folder, in my case:
cd /usr/local/lib/node_modules/nativescript/lib/services/livesync
  1. Edit the livesync-service.js file with your editor at line 109
let watcher = choki.watch(pattern, { ignoreInitial: true, cwd: syncWorkingDirectory }).on("all", (event, filePath) => {

and add

awaitWriteFinish: { stabilityThreshold: 500, pollInterval: 100 }

to the options of the watch like this:

let watcher = choki.watch(pattern, { ignoreInitial: true, cwd: syncWorkingDirectory, awaitWriteFinish: { stabilityThreshold: 500, pollInterval: 100 } }).on("all", (event, filePath) => {
  1. You can then test and see if this fixes the issue. In case you experience problems you can either revert your change or re-install the nativescript.

We're waiting for your feedback

@jbsouvestre
Copy link

Hey @yyosifov ,

Thanks for the quick answer.

I just confirmed that your fix works ! Thanks !

@ovovchuk
Copy link

Hello, @yyosifov your fix works for me as well. Thanks.

@dtopuzov
Copy link
Contributor

@jbsouvestre @echap @straussCS @fvonberg @CanKattwinkel @daveware-nv

Fix is already available in master branch of the CLI, you can try it with:

npm un -g nativescript
npm cache clean
npm i -g nativescript@next

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants