node-red-nodes
node-red-nodes copied to clipboard
Tail node and corresponding tests don't work on Windows
There's a comment associated with the tail node saying "Linux and windows only". Would be nice if possible to make this work for Windows.
Also, the corresponding unit test fails on Windows, not only because the actual functionality doesn't work, but because there's a timing window where we look to write to the test file but the file does't exist. This has been seen once or twice on the Travis build. Note that the test uses
fs.unlinkSync(fileToTail);
which on linux deletes the file but on windows only deletes when the running process completes.
See also the comments in node-red/node-red#329
FYI: https://github.com/lucagrulla/node-tail
Have just pushed 43ad8706aa067646cf7a6281c1aee49898f3d5ec which fixes a timing window in the tail node tests. The test file was being written asynchronously to the test running - so it was possible that the file didn't exist when the test tried to use it.
I've replaced that code with using a static file in the resources directory.
I've also added some TODOs on the node itself - including one to move over to node-tail.
Finally, we should add a test for when the file being tailed is deleted and recreated. This is why the -F argument is being used - so we continue to tail the new file. Once we have that test in place, we can do the rewrite to use node-tail.
Since the proposal is to switch to use node-tail and the current tail node isn't supposed to work on windows I'm just making a note here rather than proposing to fix the test....the tail node tests fail for me me on windows because there's an extra character found - "\r". Just to keep in mind there may still be differences between windows and linux.
see also issue node-red/node-red#337
There are several packages that do the equivalent of tail... some claim to support files going away / being renamed - which is functionality we want... eg https://www.npmjs.org/package/always-tail and https://www.npmjs.org/package/tailfd ... so need to evaluate them to select the most appropriate (as well as https://www.npmjs.org/package/tail )
It would also be nice if they support the behaviour created by the -n 0 option of the real tail command - ie only output new lines.
In my testing, always-tail is the closest to what we want. If/when they accept my pull-request, it'll be perfect.
Bumping from the 0.9 release; the PR still hasn't been accepted and the issue doesn't warrant holding up the release.
Moved this issue over from the core repo so it follows the Tail node that was moved to this repo some time ago.