Skip to content

Conversation

kcross-ctoken
Copy link

Summary

Fixes a data race when using assert.Eventually so the variables can be safely used after a timeout

This was found in my test code when the eventually timed out and I was using something set in the closure. It required the --race go test parameter set.

Changes

added a wait group to wait for the end of the go routine call in assert.Eventually

@kcross-ctoken kcross-ctoken changed the title Fix: to fix a data race condition after a timeout on an assert.Eventually Fix: a data race condition after a timeout on an assert.Eventually call. Aug 14, 2025
Copy link
Collaborator

@brackendawson brackendawson left a comment

Choose a reason for hiding this comment

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

I think you've found a valid bug but your fix changes the behavior of Eventually. Right now it will return and fail the test as soon as the timeout is hit but with this change it will now wait until the last condition function returns. While I actually think waiting is the better behavior it's not something we can just go changing.

This also doesn't fix the issue for other Eventually/Consistently/Never assertions.

@brackendawson
Copy link
Collaborator

#1657 would resolve the issue here I believe.

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