# Watch node - add option to wait till file write completion

**URL:** <https://discourse.nodered.org/t/watch-node-add-option-to-wait-till-file-write-completion/59999>\
**Category:** Feature Requests\
**Created:** [17 March 2022 17:00 UTC](https://discourse.nodered.org/t/watch-node-add-option-to-wait-till-file-write-completion/59999 "2022-03-17T17:00:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [17 March 2022 17:00 UTC](https://discourse.nodered.org/t/watch-node-add-option-to-wait-till-file-write-completion/59999/1 "2022-03-17T17:00:51Z")

</div>

The watch node may fire multiple times during the writing of a file. This means that it is often (very often in my experience) necessary to follow the watch node with a Trigger to delay the message till the write has finished.  
The underlying library (which I believe is chokidar) has an option awaitWriteFinish which is documented as delaying the watch event until a little time after the file stops being written to. It would be useful if the Watch node had an option to enable that in order to avoid the requirement for a Trigger node.  
This problem is regularly encountered on the forum, see [Using a watch node](https://discourse.nodered.org/t/using-a-watch-node/59968) for example.

**Correction: The watch node does not use chokidar, it uses fs.notify**

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [17 March 2022 17:37 UTC](https://discourse.nodered.org/t/watch-node-add-option-to-wait-till-file-write-completion/59999/2 "2022-03-17T17:37:02Z")

</div>

Looking forwards to the pull request:-)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [17 March 2022 17:55 UTC](https://discourse.nodered.org/t/watch-node-add-option-to-wait-till-file-write-completion/59999/3 "2022-03-17T17:55:47Z")

</div>

Sadly I don't have the time to get into core development at the moment. I presume that _is_ core.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [17 March 2022 17:58 UTC](https://discourse.nodered.org/t/watch-node-add-option-to-wait-till-file-write-completion/59999/4 "2022-03-17T17:58:49Z")

</div>

ah well - some other time then.  
It is core but uses the fs.notify library so may or may not expose the call you want - if anyone wants to look/have a go.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 March 2022 10:13 UTC](https://discourse.nodered.org/t/watch-node-add-option-to-wait-till-file-write-completion/59999/5 "2022-03-18T10:13:11Z")

</div>

To close this off for the moment, since it has become clear that the node uses fs.notify, not chokidar, it would likely require a complete rewright. So, unless someone takes this on, we shall have to carry on with what we have. Which works fine, except for the fact that it often needs to be followed by a Trigger node.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [17 May 2022 10:13 UTC](https://discourse.nodered.org/t/watch-node-add-option-to-wait-till-file-write-completion/59999/6 "2022-05-17T10:13:51Z")

</div>

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