Fix forwardingStreamHandler errgroup race#317
Merged
EdSchouten merged 1 commit intobuildbarn:mainfrom Feb 4, 2026
Merged
Conversation
|
a84a20e to
a374a9c
Compare
Contributor
Author
|
This PR now adds |
Member
|
I don't know. I'd rather not make program.Group fat. Stuff should just clean up their own goroutines. What are your thoughts on doing something like this instead? var propagatedError atomic.Pointer[error]
ctxWithCancel, cancel := context.WithCancel(ctx)
defer cancel()
x, err := NewStream()
...If we want to propagate errors from the background goroutine, we do this: propagatedError.Store(err)
cancel() |
Contributor
Author
|
Okay, I resolved it with |
a374a9c to
a38a942
Compare
Member
|
Completely forgot about CancelCauseFunc. Nice! |
a38a942 to
136b202
Compare
EdSchouten
reviewed
Feb 4, 2026
Commit 5b5db75, "Add generic gRPC stream forwarding (buildbarn#306)", introduced a flakiness in the grpc_test due to calling `errgroup.Go(func() error { return err })` when an error had occurred in a go routine that was asynchrounous to the errgroup.Wait() call. This could lead to `errgroup.Go()` being called just when `errgroup.Wait()` was about to return, which is not allowed.
136b202 to
c76188c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

The commit Add generic gRPC stream forwarding (#306), introduced a flakiness in the grpc_test due to calling
errgroup.Go(func() error { return err })when an error had occurred in a go routine that was asynchrounous to theerrgroup.Wait()call. This could lead toerrgroup.Go()being called just whenerrgroup.Wait()was about to return, which is not allowed.