node-syncthing icon indicating copy to clipboard operation
node-syncthing copied to clipboard

Updated events array is undefined

Open Tstassin opened this issue 6 years ago • 3 comments

While fetching events, after some time I got this error :

(node:11544) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'forEach' of undefined
    at PATH_TO/node_modules/node-syncthing/lib/event-caller.js:49:18
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
(node:11544) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:11544) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Error is here :

https://github.com/JodusNodus/node-syncthing/blob/ef56646ecea32ffe055c1d524cb84beeac920d80/lib/event-caller.js#L43-L50

I think that the request never returns, even with an error. Should we handle this case typeof eventArr === "undefined" by throwing an error, incrementing retries and bypassing event emitting/counting steps ?

Tstassin avatar Jan 05 '19 09:01 Tstassin

Could you further debug why eventArr is undefined ? An error in the request would make the Promise unsuccefull thus never arriving in the handler (where eventArr is processed) function.

JodusNodus avatar Jan 05 '19 15:01 JodusNodus

I can confirm , a simple restart on syncthing (v1.0.1) will throw this error, crashing the app.

NunoBento avatar Apr 09 '19 15:04 NunoBento

Still an issue

sliterok avatar Sep 12 '21 10:09 sliterok