dataflow
dataflow copied to clipboard
Live-reload displays blank page on Windows 10
Attempted to run dataflow on a Windows 10 computer. Initial load of a notebook works, however changing the notebook using notepad++ causes the page to become and remain blank.
The issue is that the file is empty for the brief moment when dataflow receives a file change notification. I'm not entirely sure why Windows behaves this way but I've seen similar issues in Python modules that watch for file changes. Perhaps opening the file for writing changes the length to 0 and triggers file change notification, then it finally updates after writing completes. It's also odd that dataflow doesn't receive notification when the write completes.
On my computer Notepad++ triggers this issue every time. Atom only trigger this issue when the file becomes large enough. Notepad continued to work, but maybe my test file wasn't large enough to trigger the issue.
I did the simplest possible fix and did added a setTimeout for 100mS in run.js before attempting to read the file. In general some sort of debounce seems necessary, whether that's a fixed delay or more intelligent checks to determine when the file is no longer changing.
Thanks for the detailed report!
I'll look into this. At worst, I'll add a new option like --update-delay 100
or something if there isn't a straightforward fix, but Dataflow uses chokidar under the hood for this, so I would be surprised if there wasnt a better solution
Absolutely! And dataflow seems really nice (still exploring it!)
Good call on Chokidar; looks like it has an "awaitWriteFinish" option (default: off) that solves the problem by internally debouncing. Unfortunately the default debounce time is 2 seconds! Can override the default to 50ms like this:
{'awaitWriteFinish': {'stabilityThreshold':50}}
Figured I'd see what VS Code does. Interestingly while VS Code uses Chokidar for file watching on Unix/MacOS targets, it uses a C# helper app instead for Win32. This app has a 50mS debounce time:
https://github.com/microsoft/vscode-filewatcher-windows/blob/main/FileWatcher/EventProcessor.cs#L15
Just general FYI I've been having the same issue on VS Code (it's bad enough to make Dataflow unusable) but did verify that changing https://github.com/asg017/dataflow/blob/8c96fba53d58d862baf0192aa2a5c8ec6e844a34/src/run.js#L156 to
chokidar.watch(notebookPath, {awaitWriteFinish: {stabilityThreshold: 50, pollInterval: 50}})
solves the issue perfectly every time.
I can look into making a PR for this if it would be helpful.