Closed austince closed 3 months ago
hmm - can you share the code where you found this. sometimes that race condition indicates that your concurrent By
is outliving the lifecycle of the spec in question
sometimes that race condition indicates that your concurrent By it outliving the lifceycle of the spec in question
Hmm maybe that's it. Essentially we have a mock that registers a callback and is called concurrently by a process that is may or may not be stopped when the test is finished.
Right - you might need to fix that instead. One of the drawbacks of the DSL is that invoking it outside of the lifecycle of the intended spec can result in attaching information to the wrong spec.
That makes sense -- thanks! Would the same issue occur with assertions that outlive the test lifecycle, or are those safely ignored?
And last question -- would using a DeferCleanup
to ensure these callbacks are deregistered have appropriate guarantees, or would we need to do it within the It
block explicitly?
DeferCleanup
would work. note that you’ll need to make sure it actually exits whatever goroutine it spun up before you exit the cleanup callback. sometimes these sorts of things don’t block when you tell them to stop. they just stop… eventually. that sort of thing could still leak between specs.
Thank you!
I'm not sure this is the right fix, but found a race condition when using By() concurrently.