fatoldsun00 / node-red-contrib-watchdirectory

Watch directory for create, update, delete event
9 stars 6 forks source link

Bug with appearing / disappearing dirs (causing crash of nodered) #8

Open lost-bits opened 2 years ago

lost-bits commented 2 years ago

I in documented a issue, which is also caused by your node.

https://github.com/node-red/node-red/issues/3355

lost-bits commented 2 years ago

Okay, so here is the problem im detail:

as @Steve-Mcl wrote, it is caused by an error which the node throws around in line 66 of file node-red-watchdirectory.js.

    watcher.on('ready', () => {
      setTimeout(() => {
        node.status({fill:"yellow", shape: "ring", text: "Listening..."})
      }, 10000)
    }).on('error', (err) => {
      node.status({fill:"red", shape: "dot", text: "Error : "+err.message})
      throw(err)
    })

if you replace the throw(err) by node.error(err), it will report in node RED and keep it alive, even if the error occurs more than one time.

image

Even with this new kind of error handling, the node does not start to recover.

What I found out so far, is that:

1) this only happens, IF you configured a NON-existing dir to watch .... 2) you create a dir afterwars (no matter how the dir is called)...

If the dir exisits, and it is watched, the node does not fail to error.

fatoldsun00 commented 2 years ago

Hi, i don't maintain this repo anymore, but i can change owner if there are somebody who want maintain.

lost-bits commented 2 years ago

Uhh ... thats sad ... I use this node at the moment a bit... and I will try to fix it (if possible) ... but since I dont know where at chokidar the error is created, I guess, i should ask there ...

If I find the fix, I will post it here ...

fatoldsun00 commented 2 years ago

you can push a MR and i can merge

lost-bits commented 2 years ago

Will do so, if I find the solution. The current one in the issue just fixes the NodeRED crash issue.

bombjackit commented 4 months ago

@fatoldsun00 I have create a pull request (https://github.com/fatoldsun00/node-red-contrib-watchdirectory/pull/12) with a little change that solve this problem (I tested in my environment node-red 3.1.3, windows 10, node.js 18 and act as expected).

Commit is identical as that proposed by @lost-bits.

bombjackit commented 4 months ago

@fatoldsun00 thanks for merging pull request, could you publish this update with npm ?

fatoldsun00 commented 4 months ago

Hi, it's done. Thansk for your PR

bombjackit commented 4 months ago

Thanks to you @fatoldsun00