Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

(rustwasm template) wrangler preview --watch enters "detected changes" loop #618

Closed
toinbis opened this issue Sep 18, 2019 · 14 comments · Fixed by #699
Closed

(rustwasm template) wrangler preview --watch enters "detected changes" loop #618

toinbis opened this issue Sep 18, 2019 · 14 comments · Fixed by #699
Assignees
Labels
bug Something isn't working investigate

Comments

@toinbis
Copy link

toinbis commented Sep 18, 2019

🐛 Bug Report

Wrangler 1.3.1 with rust template has major malfunction in the wrangler preview --watch. After command is launched all seems as expected. Though after first edit on a watched file the refresh cycle keeps spinning non-stop. Thanks a lot for looking into this and advising how to solve without waiting next release of wrangler.

Environment

  • operating system: OSX 10.13.16
  • output of rustc -V: rustc 1.37.0 (eae3437df 2019-08-13)
  • output of node -v: v10.16.2
  • output of wrangler -V: 1.3.1

Tried on both node and cargo installations with wrangler.

Steps to reproduce

  1. wrangler preview --watch
  2. Make an edit in, i.e. src/lib.rs file.

What did you expect to see?

Single auto-realtime-update cycle.

What did you see instead?

7NM5TfhgYO
I.e. the refresh cycle keeps cycling nonstop without me touching the code at all .

@ashleygwilliams ashleygwilliams added bug Something isn't working investigate labels Sep 19, 2019
@ashleygwilliams
Copy link
Contributor

Hi @toinbis ! Thanks for filing and sorry you are running into this. I'll spend some time tomorrow reproducing and focusing on a fix!

If you happen to run into any other clues or info, please feel free to share!

@ashleygwilliams ashleygwilliams self-assigned this Sep 19, 2019
@toinbis
Copy link
Author

toinbis commented Sep 19, 2019

Hi @ashleygwilliams . Thanks a lot for looking into it! From my side I borrowed colleagues macbook with no rust or wrangler installed whatsover. Ran:
$ curl https://sh.rustup.rs -sSf | sh
cargo install wrangler
wrangler generate myproject --type="rust" && cd myproject
wrangler preview --watch -> browser opened the preview window successfully
(in other terminal) cd myproject && vim src/lib.rs -> the same loop started just by opening the file itself without doing any modification. It probably reacted to vim's temp file creation?.

So as of now at least can confirm that managed to reproduce it on another system.
Am just picking up rust & wasm basics, so sadly won't be able to help in debugging this much deeper.

@gabbifish
Copy link
Contributor

Hi @toinbis! Could you let us know which text editor you're using to edit your Worker? Ones like vim can constantly trigger the file watching system, since they use swap files. We can look into having the watcher ignore dotfiles like swapfiles in the future.

@toinbis
Copy link
Author

toinbis commented Sep 23, 2019

Hi Gabbi, thanks for looking into this. I initially hit this with my VSCode. Now after you've asked also tried VSCode with my colleague computer with fresh rust/wrangler installation - same. And just now i've downloaded vanilla sublime installation. Only added toml plugin. And used iTerm to launch the wrangler preview --watch in a newly generated wrangler generate projectname --type="rust" directory. The results is below:

sublime

I imagine there might be something specific about mine (and my colleagues?) system, though have no idea how to get to the root of the problem. Yes, vim keeps creating temp file, but I only need to open it and the chain starts. With sublime, of I only open the file - nothing happens. It means just opening does not trigger the refresh. But after I hit save - the loop starts and keeps rolling even I close all the files. It feels as if the following refreshes are triggered by some output generated by initial refresh.

@toinbis
Copy link
Author

toinbis commented Sep 23, 2019

Tried one more system - old macbook with OSX El. capital 10.11.
a) Installed rustup w/cargo;
b) installed wrangler via cargo;
c) started wrangler generate projname --type="rust" in VSCode terminal;
d) tried editing lib.rs with VSCode and save - after saving the loop had started.
e) closed VSCode and opened two terminal windows;
f) In first window copied the lib.rs to temporary folder out of wrangler project directory & edited the lib.rs.
e) In second window started wrangler preview --watch;
f) In first terminal copied cp lib.rs ./wrangler_project/src/. - the loop started.

It's the 3rd system out of 3 (all OSx) I manage to replicate the bug. Am starting to consider this might really be a real issue, not just something with my system configuration.

Also have to point that at least the recent attemts were made by running wrangler preview --watch instantly after new project without launching wrangler config or editing the cargo.tml file.

@DaleLJefferson
Copy link

DaleLJefferson commented Sep 24, 2019

I'm able to recreate this issue on

MacOS 10.14.6
rustc 1.39.0-nightly (66bf391c3 2019-09-23)
wrangler 1.3.1

Steps to reproduce (Mac Terminal no editor):

wrangler generate my-app https://github.com/cloudflare/rustwasm-worker-template
cd my-app
wrangler preview --watch
// Just doing cd my-app in another terminal is enough to set off the loop
touch src/lib.rs

@gabbifish
Copy link
Contributor

I was able to reproduce this issue on my machine as well, and I have developed a fix for it. Check out #699 for more details, but the bottom line up front is that wrangler publish --watch watched over an entire Rust project directory, including the target files. When a change to the source code occurred, it started a build process, which in turn emitted more filesystem events and triggered the live reload repeatedly.

Thank you so much for bringing up this issue, and we're sorry for the inconvenience!

@toinbis
Copy link
Author

toinbis commented Sep 24, 2019

Thank you so much for looking into this and taking your time to prepare the fix! Do you think it'll make it's way into 1.4.0 or it's too late for quite some changes in the codebase this fix brings in?

P.S. Congrats on the Cloudflare birthday week! Looking forward especially to the fridays release! :)

@DaleLJefferson
Copy link

DaleLJefferson commented Sep 25, 2019

Thanks for looking into this @gabbifish but I installed #699 and it does not seem to be fixed.

MacOS 10.14.6
rustc 1.39.0-nightly (66bf391c3 2019-09-23)

cargo install --force --git https://github.com/cloudflare/wrangler.git --branch gabbi/fix-#618
wrangler --version // wrangler 1.4.0-rc.3
wrangler preview --watch
touch src/lib.rs // Detected changes loop is triggered

Maybe @toinbis could test this as well.

I believe I have the correct code

Replaced package `wrangler v1.3.1` with `wrangler v1.4.0-rc.3 (https://github.com/cloudflare/wrangler.git?branch=gabbi/fix-#618#e3a22602)` (executable `wrangler`)

@toinbis
Copy link
Author

toinbis commented Sep 25, 2019

I can confirm that after uninstalling the JS version of wrangler and installing the gabbi/fix-#618 following @DaleLJefferson terminal commands the loop starts after editing a file.

@gabbifish
Copy link
Contributor

@DaleLJefferson @toinbis thanks for testing! I have reason to believe the bug you're running into above must be the result of path logic differing between your Macs and my Linux machine, so I'll investigate. Thank you so much for helping me out and testing :) I'll update this thread when I think I have the fix for other operating systems.

@motiejunas
Copy link

So, is there any news? It's impossible to work like this. @ashleygwilliams @gabbifish

@gabbifish
Copy link
Contributor

We plan to have a fix out when we release 1.5.0 at the end of this week. Thank you for your patience!

@gabbifish
Copy link
Contributor

a fix has been merged and will be released with wrangler 1.5.0. We have successfully tested it on linux, OSX, and Windows :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working investigate
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants