Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
client: handle errors in connectAndInspect
As `DataCollector` always returns the data it managed to collect successfully and passes errors as a separate object, `connectAndInspect` has put errors as `_errors` property of the result to be consistent. This was a horrible design decision that was counter-intuitive and would only lead to the lack of proper error handling in application code (and has actually led in our integration test). Worse than that, even this `_errors` property would never have been populated with errors because of a bug in `connectAndInspect`. A patch for the bug (just in case we ever want to backport it): diff --git a/lib/client.js b/lib/client.js index 83236d9..b0436fd 100644 --- a/lib/client.js +++ b/lib/client.js @@ -124,7 +124,7 @@ Client.prototype.connectAndInspect = function( interfaces.forEach((interfaceName) => { connection.inspectInterface(interfaceName, (error, appInterface) => { if (error) { - appInterface = null; + appInterface = error; } collector.collect(interfaceName, appInterface); }); The proper solution would have been to stop inspecting interfaces as soon as the first error occurs and return it as the first argument of the callback. As it turned out, it was quite tricky to do with DataCollector, and some other issues were found while inspecting `metasync` sources too. Fixing these problems requires backwards-incompatible changes and will certainly happen in the next semver-major release of `metasync`, but we need a quick fix here. For this reason, the function was refactored to use promises. PR-URL: #105 Reviewed-by: Mykola Bilochub <nbelochub@gmail.com>
- Loading branch information