yoga2 icon indicating copy to clipboard operation
yoga2 copied to clipboard

Live reload doesn't work on Windows

Open jferrettiboke opened this issue 5 years ago • 14 comments

Describe the bug Live reload doesn't work on Windows after running the server. I need to restart the server manually each time I do changes.

Versions (please complete the following information):

  • OS: Windows 10 Pro
  • Node: v10.15.3
  • yoga dependency: v0.0.18

jferrettiboke avatar Apr 02 '19 13:04 jferrettiboke

doesn't seem to be working on Mac for me either

swolidity avatar Apr 02 '19 17:04 swolidity

I have also noticed this on Linux (Arch, 5.06). Using yoga v0.0.18, node v11.6.0.

yoga dev does a great job of updating the generated types and schema, but doesn't actually restart the server process. For example, any changes I make to resolver code do nothing until kill the process and run yoga dev again.

Dieff avatar Apr 10 '19 20:04 Dieff

Maybe this is because yoga2 now uses ts-node instead of ts-node-dev.

Currently yoga dev only auto restart after each yarn prisma deploy, but I guess most developers expect it to auto restart on all file changes within src.

[EDIT] most examples in https://github.com/prisma/prisma-examples are using ts-node-dev and they work fine.

beeplin avatar Apr 14 '19 16:04 beeplin

@beeplin this is more than likely the issue. I've tried replacing ts-node with ts-node-dev, but I've been unable to figure out how to start ts-node-dev programmatically.

DevanB avatar Apr 15 '19 14:04 DevanB

@DevanB Yes, yoga dev uses ts-node's register to compile .ts files programmatically, which is probably not available in ts-node-dev.

A more feasible way, I guess, might be use nodemon or node-dev to wrap yoga dev.

beeplin avatar Apr 15 '19 14:04 beeplin

Hey there,

I'll investigate that issue soon. The dev command is working fine for me on OSX.

Although we're not using ts-node-dev, we're replicating ts-node-dev behavior to watch/recompile files on-the-fly.

All .ts files are supposed to be watched in your folder, not only the one related to prisma deploy, this is a bug.

I suspect the issue is coming from chokidar, the file watcher we use.

Weakky avatar Apr 15 '19 14:04 Weakky

It seems that it should be working that way (based on the code) @Weakky, but I can reproduce it consistently by doing the following:

  1. Create a new mutation or query that uses context to call a method (like I have an auth, email, prisma, and stripe context).
  2. Create that method on the context.
  3. Execute that query/mutation.

I consistently get back that X method is not a method on Y object (the context).

DevanB avatar Apr 15 '19 15:04 DevanB

I change it from chokidar to node-watch and it fixed it. You see the changes here

williamluke4 avatar Apr 19 '19 21:04 williamluke4

Hey there,

The dev command should now work properly, checkout the release note of [email protected] here https://github.com/prisma/yoga2/releases/tag/v0.0.19

The problem wasn't about file watching, but about require.cache not being properly invalidated between two reloads.

If some of you still have the problem, then we'll have to investigate whether chokidar is also a source of issues. VSCode uses it thought, so we should be able to use it reliably.

@jferrettiboke I wasn't able to test on Windows, any feedback would be much appreciated 🙏

Weakky avatar Apr 26 '19 14:04 Weakky

@Weakky I tested v0.0.20 on Windows, but unfortunately the hot reload is still not working:

  1. yarn create yoga (select 'from scratch' & 'mini')
  2. yarn add express (the generated code seems to lack express dependency)
  3. yarn dev
  4. make some change, and no live reload.

beeplin avatar May 01 '19 13:05 beeplin

@jferrettiboke I wasn't able to test on Windows, any feedback would be much appreciated 🙏

@Weakky It doesn't work on Windows yet. Still the same issue.

jferrettiboke avatar May 02 '19 12:05 jferrettiboke

@Weakky Any solution to this? It's almost impossible to work in this way.

jferrettiboke avatar May 13 '19 11:05 jferrettiboke

Does anyone still have the same issue than me? I would appreciate if someone, hopefully @Weakky, could have a look into this and give us a fix. I am using yoga in a project, and it's hard to make changes because I need manually to restart the server each time. Thanks in advance, guys.

jferrettiboke avatar May 23 '19 11:05 jferrettiboke

+1 @jferrettiboke just stopped using yoga2 in my project due to this issue.

beeplin avatar May 23 '19 12:05 beeplin