danielduarte / flowed

A fast and reliable flow engine for orchestration and more uses in Node.js, Deno and the browser
https://danielduarte.github.io/flowed
MIT License
151 stars 21 forks source link

Console error misleading when a resolver does not have a return statement. #19

Closed freakpol closed 4 years ago

freakpol commented 4 years ago

When a resolver does not have a return statement, the following error appears in console, misleading on the proper way to solve the issue:

(node:56642) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'hasOwnProperty' of undefined
    at Task.mapResultsFromResolver (/.../node_modules/flowed/dist/engine/task.js:113:31)
    at /.../node_modules/flowed/dist/engine/task.js:57:38
daniel-duarte commented 4 years ago

Thanks for reporting @freakpol, will take a look.

daniel-duarte commented 4 years ago

Solved. To be included in next release. Now when a resolver returns an incorrect value, a Promise that resolves to an incorrect value or even doesn't return at all, the following error will be thrown:

"Expected resolver for task '<<your task name>>' to return an object or Promise that resolves to object. Returned value is of type '<<type returned>>'."