File-In node oddities

I may be the odd one here but wanted to check if this behaviour is normal, or if it's just me :slight_smile:

I have a File-In node set to output "a msg per line". All works as expected except for the last line, which either:
a) will not output the full msg (the Topic is missing) if there is no LF; or
b) will output the next blank line as a msg if there is a LF.

The outcome I would like is a) but obviously with the complete msg.

There are obviously easy workarounds for this, but I am just curious if anyone else gets the same outcome.


I see the same thing. The msg.topic is sent thru on every line but the last line of the file.

10/25/2019, 4:50:12 AMnode: cf302004.413cd8
test out : msg : Object
{ payload: "line 1", topic: "test out", filename: "/Users/Paul/test.txt", parts: object, _msgid: "5fdf0b45.3adad4" }

10/25/2019, 4:50:12 AMnode: cf302004.413cd8
test out : msg : Object
  payload: "line 2"
  topic: "test out"
  filename: "/Users/Paul/test.txt"
  parts: object
    index: 1
    ch: "↵"
    type: "string"
    id: "27cda854.0a2fc8"
  _msgid: "c3a748f6.3b23b8"

10/25/2019, 4:50:12 AMnode: cf302004.413cd8
msg : Object
  payload: "line 3"
  parts: object
    index: 2
    count: 3
  ch: "↵"
    type: "string"
    id: "27cda854.0a2fc8"
 _msgid: "37349951.ffffa6"

[{"id":"a8c74407.ec8b58","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"d5fe1576.59f688","type":"file in","z":"a8c74407.ec8b58","name":"","filename":"/Users/Paul/test.txt","format":"lines","chunk":false,"sendError":false,"encoding":"none","x":390,"y":860,"wires":[["cf302004.413cd8"]]},{"id":"aaf27b4b.03a708","type":"inject","z":"a8c74407.ec8b58","name":"","topic":"test out","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":860,"wires":[["d5fe1576.59f688"]]},{"id":"cf302004.413cd8","type":"debug","z":"a8c74407.ec8b58","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":570,"y":860,"wires":[]}]

Thanks Paul, glad it's not just me :sweat_smile:

FYI, I just submitted a PR to fix this. It was a one line addition to the code.

1 Like

Just looked at PR - maybe add a link to this thread for info?

Good idea - done!

1 Like

Anyone know if this was fixed? I couldn't find Paul's PR for it.

I don't thnk it made it into 1.0.3 so it should beinthe next release

Thanks Paul.

em - AFAICT the changed code IS in 1.0.3


1 Like

Duhh, I went and tested it and it didn't work but @cymplecy made me think so I went and looked and (head slap) The place I just tested it is on 1.0.2 (double head slap)

yup it is in 1.0.3 (Thanks Simon!)

Ok, well this appears to be some sort of Friday 13th joke but...

the issue of sending an extra msg at the end of the file still appears to exist, when the File In node is set to "a msg per line". I notice that the filename property is missing from the last msg.

Can someone else confirm?

You are correct that filename is missing
Screen Shot 2019-12-14 at 5.25.58 AM

If you go read the Pull Request you will see that @dceejay was concerned that th message needed to be cloned and worried about the hit to performance and that would take some thinking after they got out v1.0.3. So the pr to fix getting the last message was accepted but there are still issues with everything that comes out with the last message.

For example, if you put a change node before the file-in node and set 'msg.mytest' to 'cheers!', it does not come out as part of the msg that exits the file-in node.

Sorry, not following. How does that affect the fact that an extra msg is being sent with an empty payload when it shouldn't? Or is it just me seeing this?

I thought this behaviour was as expected, in that only msg.payload or msg.topic would be passed on?

My input file has three line. All three lines are showing in the debug and nothing else.

Have you updated node-red to 1.0.3?

Is it possible you have a blank line at the end of the file?

1 Like

I was afraid you would say that.


I have created a number of test files with and without linefeeds at the end just to see the results. All the same, with one extra msg tacked on the end. As previously mentioned, the last msg has no filename property, and also no payload.

Grrr, hate mysteries.

How about you two exchanging files to test out?

Here is my test file - three lines with
line 1
line 2
line 3
test.txt (20 Bytes) test.txt (21 Bytes)
and here are my settings:
Screen Shot 2019-12-14 at 10.00.45 AM
and here is the debug:

12/14/2019, 10:02:37 AMnode: efa512e0.b2a2e
test out : msg : Object
{ payload: "line 1", topic: "test out", filename: "/Users/Paul/test.txt", parts: object, _msgid: "9012d0a8.67584" }
12/14/2019, 10:02:37 AMnode: efa512e0.b2a2e
test out : msg : Object
{ payload: "line 2", topic: "test out", filename: "/Users/Paul/test.txt", parts: object, _msgid: "7dc19a9.d5c7664" }
12/14/2019, 10:02:37 AMnode: efa512e0.b2a2e
test out : msg : Object
{ payload: "line 3", topic: "test out", parts: object, _msgid: "6d08dff6.1fb15" }
1 Like

Apologies for wasting everyone's time on this. :unamused:

Apparently the editor Nano must be used with the -L switch to suppress eof linefeed. Even though without -L the editor doesn't count the extra line. Think it's time to find a better editor.


I never knew that!

But I think nano was designed to be the muggle editor for Linux so given that, adding the extra LF would be considered a good feature for people using it to edit config files

Now I know about it, I can save that one extra keypress :slight_smile: