node-red-nodes icon indicating copy to clipboard operation
node-red-nodes copied to clipboard

Tail node and corresponding tests don't work on Windows

Open hbeeken opened this issue 11 years ago • 9 comments

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.

hbeeken avatar Aug 05 '14 08:08 hbeeken

See also the comments in node-red/node-red#329

knolleary avatar Aug 06 '14 18:08 knolleary

FYI: https://github.com/lucagrulla/node-tail

hbeeken avatar Aug 07 '14 13:08 hbeeken

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.

knolleary avatar Aug 07 '14 14:08 knolleary

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.

hbeeken avatar Aug 11 '14 08:08 hbeeken

see also issue node-red/node-red#337

hbeeken avatar Aug 13 '14 15:08 hbeeken

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.

dceejay avatar Aug 21 '14 09:08 dceejay

In my testing, always-tail is the closest to what we want. If/when they accept my pull-request, it'll be perfect.

knolleary avatar Sep 07 '14 21:09 knolleary

Bumping from the 0.9 release; the PR still hasn't been accepted and the issue doesn't warrant holding up the release.

knolleary avatar Sep 17 '14 22:09 knolleary

Moved this issue over from the core repo so it follows the Tail node that was moved to this repo some time ago.

knolleary avatar Oct 09 '20 16:10 knolleary