Skip to content

Reducer does not return an error when the original stream has only 1 item #71

@vadimi

Description

@vadimi

Hello, thanks for the awesome library. I'm hitting an issue with the reducer that doesn't return an error when the original stream has only 1 item and the intermediate step returns it. Here is a quick reproduction:

items := rill.FromSlice([]int{1}, nil)
mappedItems := rill.Map(items, 1, func(item int) (int, error) {
	return 0, fmt.Errorf("an error occurred at item %d", item)
})
_, _, err := rill.Reduce(mappedItems, 1, func(prev, current int) (int, error) {
	return 0, nil
})
fmt.Println("done")
fmt.Println(err)

The error is nil in this case.

I was digging into the code a bit and it looks like the line setReturns(res.Value, ok, nil) ignores the error. Should it be something like this instead? setReturns(res.Value, ok, res.Error)?

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