openfaas / of-watchdog

Reverse proxy for STDIO and HTTP microservices
MIT License
262 stars 115 forks source link

Fixes bug in pipeToProcess #30

Closed thomasjpfan closed 6 years ago

thomasjpfan commented 6 years ago

Signed-off-by: Thomas Fan thomasjpfan@gmail.com

Fixes bug in pipeToProcess when recording errors.

Description

Since there are only two go routines, a slice of length 2 is used to store errors. After wg.Wait() the errors are combined and returned.

Motivation and Context

In the previous implementation, when both the read and write go routines has an error, there were no guarantees that the errors slice gets populated with two errors. The go routine processing the errChannel may not have had the opportunity to process the second error when wg.Wait unblocks.

How Has This Been Tested?

Unit tests were added to test the different error cases.

Types of changes

Checklist:

thomasjpfan commented 6 years ago

Closing this for now to adapt to openfaas's workflow.