Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

kzantow
Copy link
Contributor

@kzantow kzantow commented Oct 16, 2025

Description

This PR updates the go-sync library to return panics as errors during concurrent calls, and adds an option to loudly log, but not fail on errors. This option will allow users to opt in to behavior in their CI environment, for example, that errors including panics will not cause the process to return nonzero, but instead only be error logged.

Type of change

  • Feature

Checklist:

  • I have added unit tests that cover changed behavior
  • I have tested my code in common scenarios and confirmed there are no regressions
  • I have added comments to my code, particularly in hard-to-understand sections

TODO:

  • configuration to continue in the event of a non-unknown error bubbling up to the top with --continue-on-error or similar

Signed-off-by: Keith Zantow <[email protected]>
Signed-off-by: Keith Zantow <[email protected]>
return errors.Join(out...)
}
// handle PanicErrors directly, since these are wrapped errors
if e, ok := err.(sync.PanicError); ok {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: why not errors.As?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function recursively unwraps errors, it doesn't need to let errors.As also do this

prefix := strings.TrimSuffix(err.Error(), wrapped.Error())
return fmt.Errorf("%s%w", prefix, got)
// if there is not a wrapped error, fall through to visit the error directly
if wrapped != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit / non-blocking: this would be a little more readable with a guard clause instead of wrapping (e.g. instead do if wrapped == nil { return nil} ahead of the remaining logic.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a little different behavior than this -- if wrapped is nil, it continues to visit the container

@kzantow kzantow marked this pull request as draft October 20, 2025 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants