Skip to content

Updated events array is undefined #9

Description

@Tstassin

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 :

req({ method: 'events', endpoint: false, attr: attr }).then(function (eventArr) {
//Check for event count on first request iteration
if (since != 0) {
eventArr.forEach(function (e) {
_this.emit(lowerCaseFirst(e.type), e.data);
});
}

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 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions