implement err group as an alternative to a wait group so errors from activities can be propagated upwards nicely - #462
Merged
cschleiden merged 4 commits intoMay 29, 2026
Conversation
…activities can be propagated upwards nicely
There was a problem hiding this comment.
Pull request overview
This PR adds a workflow-native ErrGroup (errgroup-style) abstraction so concurrent workflow coroutines can return errors that are aggregated and propagated via Wait, and includes a sample demonstrating the new API.
Changes:
- Expose
workflow.ErrGroupandworkflow.WithErrGroupas public workflow APIs. - Implement
internal/sync.ErrGroupwith tests for success and “first error wins”. - Add a new sample (
samples/concurrent-errgroup) demonstrating concurrent activity execution with error propagation.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
workflow/sync.go |
Exposes the new ErrGroup type alias and WithErrGroup helper at the workflow API layer. |
internal/sync/errgroup.go |
Implements the scheduler-compatible errgroup abstraction. |
internal/sync/errgroup_test.go |
Adds unit tests validating basic ErrGroup behavior. |
samples/concurrent-errgroup/concurrent_errgroup.go |
Demonstrates usage of workflow.WithErrGroup in a runnable sample. |
Comments suppressed due to low confidence (2)
internal/sync/errgroup.go:40
errGrouphas awaitingflag intended for misuse detection, but it’s currently unused beyond being set inWait. Either remove it to avoid dead state, or use it to enforce a clear contract (e.g., disallow callingGoafterWaitstarts, similar toWaitGroup).
This issue also appears on line 58 of the same file.
// track if Wait was called to detect certain misuses (optional)
waiting bool
internal/sync/errgroup.go:60
Waitsetswaiting=true, butGodoes not check it. This allowsGoto be called afterWaithas started/returned, which can makeWaitreturn without waiting for the newly launched coroutine (i.e., silent misuse). Consider adding a panic/guard inGowhenwaitingis already true (mirroringWaitGroup’s misuse detection) so incorrect usage fails fast.
func (g *errGroup) Go(f func(Context) error) {
g.n += 1
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
cschleiden
reviewed
Feb 28, 2026
Future.Get does not observe ctx.Done, so the doc comment promising cancellation-aware Wait was incorrect. Aligns with WaitGroup behavior. Also wires up the waiting flag to panic on Go called after Wait, matching the WaitGroup.Add misuse detection pattern.
DerkSchooltink
force-pushed
the
feature/implement-err-group
branch
from
April 29, 2026 20:24
b0a3bae to
8968430
Compare
cschleiden
approved these changes
May 25, 2026
cschleiden
enabled auto-merge (rebase)
May 25, 2026 03:13
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.
implement #461