Skip to content

"Reflect" behavior for collecting errors/results and continuing. #942

@aearly

Description

@aearly

Related to #349 #334 #531 .

There have been many requests for a behavior where when an iterator calls back with an error, the error is collected, and execution continues. There have been a couple attempts at this feature, but the implementations fall short.

In theory, this would be applied to just about any async function, map, series, parallel, forEachSeries, etc.. I'd like to support this broadly, but without having to create duplicate implementations for each function. Something we can wrap existing functions with, without having to modify the implementations.

We also need to settle on what the name is for this type of behavior. These have been proposed:

  • mapCollect / parallelCollect / eachSeriesCollect
  • mapContinue / parallelContinue / eachSeriesContinue
  • mapAnyway / parallelAnyway / eachSeriesAnyway
  • mapMaybe / parallelMaybe / eachSeriesMaybe
  • mapResume / parallelResume / eachSeriesResume

Lastly -- how should the collected results be passed to the final callback?

  • callback(null, {errors: [], results: []])
  • callback(null, [Error, results, results, Error, results..])
  • callback(null, [{err: null, result: results0}, {err: Error, result: null}, ...])
  • callback(null, results, errors)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions