-
-
Notifications
You must be signed in to change notification settings - Fork 161
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
Watch not working with docker #266
Comments
I don't use Docker but if you want to investigate and open a PR, feel free. BTW, the watcher used is chokidar, so perhaps it's a bug in that. |
Okay, I will check and see if I can find the issue. |
Hi @privatenumber, It is mentioned in Chokidar documentation that we need to set I tested locally and it seems to work but the problem is setting it to true can cause performance issue. Then I checked Nodemon to see how they have handled this and found that they use a flag Shall I add a similar flag to set |
Thanks for the investigation. Ideally no new flags... Node.js already added How does Node.js's watch handle this? |
Thanks for the reply. |
Okay, lets add a --poll flag that accepts a interval value. |
Actually, it may not be necessary if we change watchers: #246 Is Parcel's watcher compatible with network files? |
I am not sure. I will check. |
I checked @parcel/watcher and it also does not work with Docker on windows. In fact, no watcher can actually handle this. The problem is in Windows, Docker uses WSL2 which uses its own file system (ext4 for Ubuntu) instead of windows NTFS. So, until that issue is fixed (which will definitely take a long time) we have a few options:
I think switching to @parcel/watcher is actually a better long term option as Chokidar is a bit less active now. |
I'm having a similar issue here which is potentially related. If not, let me know and I can open a new issue. But when using this with Docker on an M2 Mac, changes to files are not being picked up. Interestingly if I use nodemon it works as expected. Example repo here. |
Both tsx and nodemon uses Chokidar to watch file changes. So, I don't think it is same issue. |
Can confirm that Chokidar works fine without TSX. I've pushed another script to the above repo as an example. |
Then your issue is probably related to #246 |
Hmm, we're actually using Node 18. Interestingly it seems to work with colima but not with Docker Desktop. For now I'm just either continuing with colima or if I really need it, I use Chokidar's polling. |
I have a similar issue but I don't know if it's related. I'm using Compose Watch instead of volumes. For the first few file changes, it works great. But after like 4-5 it just stops. I'm not sure how to debug either. In the meantime -- and the reason I'm posting this comment -- is that I resolved to using polling with chokidar. I'm still using My host OS is PopOS and I'm using a version of Alpine Linux in the container. I'm using Docker Engine (not Docker for Linux). |
@adam-beck Yes, I just tried compose watch and it is behaving weirdly. When I use:
Not sure why tsx watch stops working after some time. # compose.yml
services:
server:
build:
context: .
ports:
- 3000:3000
environment:
- CHOKIDAR_USEPOLLING=true
develop:
watch:
- action: sync
path: ./src
target: /app/src
- action: rebuild
path: package.json
target: /app |
I wrote a simple script to determine if chokidar was picking up the changes via compose watch const chokidar = require('chokidar');
// One-liner for current directory
chokidar.watch('.').on('all', (event, path) => {
console.log(event, path);
}); Every change seemed to be picked up. So I'm starting to think it's something within tsx itself. Granted, this is a JS script but I don't think that would matter. |
I'm likely going to migrate to using Parcel watcher in the near future. Can one of you give me a reproduction in a GitHub Action environment (or something similar) where I can reproduce this bug? This would help me cover this use-case. |
Hi hi, thank you for tsx. I've been using it for a month or two and I really enjoy it. I've been bit by this issue so I wanted to see if there's anything I can do to help figure it out. I've made a reproduction repo along with a couple Github actions to test the https://github.com/insanity54/tsx-issue-266/blob/master/.github/workflows/tests.yaml |
Bug description
I have created one file named
main.ts
and am usingtsx watch ./main.ts
as my start script to watch the file. Locally everything is working fine (Node 20) but when I try to run in a docker container, it does not watch changes inmain.ts
.I have mounted my local files to container.
I was expecting it to reload when I make changes in
main.ts
locally.Nothing happens.
tsx
does not reload anything.I did not get any error
Reproduction
This is my
main.ts
This is my
Dockerfile
(I have tried with node:alpine too)This is the
docker-compose.yml
Environment
Can you work on a fix?
The text was updated successfully, but these errors were encountered: