-
Notifications
You must be signed in to change notification settings - Fork 805
add options in chokidar to use polling #110
base: master
Are you sure you want to change the base?
Conversation
chiefjester
commented
Jan 23, 2020
- fixes stops watching files after first change #109
- chokidar is a transitive dependency of livereload, so passing an option to chokidar is relatively safe
- the fix was inspired by rollup.watch stops watching after first change. rollup/rollup#1666 (comment)
- tested on both macOS and Ubuntu 19 (via WSL2)
- fixes sveltejs#109 - chokidar is a transitive dependency of livereload, so passing an option to chokidar is relatively safe - the fix was inspired by rollup/rollup#1666 (comment) - tested on both macOS and Ubuntu 19 (via WSL2)
Already discussed before about chokidar. |
@frederikhors, can you give me more context? Can you give me a link on where it was discussed? |
Chokidar being the source of problems came up in #29 and #77. I don't think forcing everyone to use polling is the correct solution when there are comparatively so few systems that experience this, and polling is more resource intensive than listening for filesystem events. A note in the readme might be nice though. |
@Conduitry hey 👋🏻. Thank you for jumping in. The main problem is actually coming from rollup There's also a 3-year-old issue that keeps creeping back in. It defaults to native fs.watch which is problematic to other file systems, as taken from Node's documentation:
While we can fix this in the rollup layer, the issue was closed just by adding a configuration. This repo is a template starter for developers new to Svelte. It's going to be a problem for people switching to Windows now that WSL2 is pretty stable, and is about to go GA. Their first experience would leave a bad taste having a non-working live-reload from the get-go. Would you be open to adding a different file watcher like your library cheap-watch that'll handle file watching across different environments? I believe sapper has already adopted this. My goal here is to have a good out of the box experience to developers discovering Svelte. I don't think adding a README would cut it. DMing you in Discord as well. |
I would ask for this problem to be tackled as well. I fixed it now using the solution proposed here, using WSL2 on Windows 10 as well. I don't know what's causing the problem, but I agree with @thisguychris, this problem makes it really unattractive for new devs that are just getting into Svelte if the template is not working, especially since no one has the time to wait for a complete rebuild every time they change a few characters or CSS colors. In practice, Live Reload is an indispensable feature, IMO. And it just sucks if it doesn't work out of the box, at least for WSL2 users, it seems. |
Is there a reliable way to detect a system for which this is necessary? |
It's a known bug in WSL2 that watch events don't fire for changes to files on the host (Windows) filesystem. I don't think the default template should cater to that. As far as I know, the suggested workaround for the time being (and what I have been doing since updating from WSL1 to WSL2, to good success), is to have the project and files you're watching live inside the WSL environment, and not on the Windows filesystem. |
Can I propose that we close this PR based on the comments from @Conduitry above? |
Hi, @Conduitry 👋, Sorry for the confusion. This bug is also prevalent on a Linux machine.
I think you mistook WSL with WSL2, and if you are sure it's WSL2, then I didn't test using the Windows File system. My project is in the Linux filesystem, so non of the possible bug you mention applies here. I tested and replicated the bug in Ubuntu Machine, not just WSL2. Also, as per Node docs.
And that's the reason why I was trying to DM you last year (though I never got a reply) 😢 . So maybe we can brainstorm. I was about to propose to replace chokidar altogether with something you wrote, which is already being used in rollup. @antony, no problem closing on my side. it's still a bug though 😞 |