Write file node only errors once and always returns the payload, even when it can't write

I was playing with a flow today to create a simple API for writing data to a CSV file. If it is able to write to the file then I want it to write the data and return a simple success message. If it's not able to write to the file then I wan't to return a simple error message so it can be handled appropriately on the client side.

I've run into two difficulties:

  1. If it write to an invalid location I know will fail, it only generates an error (caught by the Catch node) the first time?

  2. The Write file node always returns the payload (even if it fails) making it much more difficult to handle and create a flow to return the correct success/error message back to the HTTP Response node.

Am I missing something obvious?

I use these file ops nodes in addition:
node-red-contrib-fs-ops

With this * fs-ops-access - Test existence and accessibility of a file or directory Node you can test if you could write a file in your desired location.

Are you using the latest version of node-red? If so then I think item 1 would be a reportable bug.

For item 2 try using a Catch node and a Complete node. If the node behaves in a well behaved way it will output to only one of those, dependent on success or failure. I have not tried it with that node though. Again, make sure you are on the latest node-red.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.