Closed Groxx closed 3 years ago
Files with Coverage Reduction | New Missed Lines | % | ||
---|---|---|---|---|
internal/internal_task_pollers.go | 8 | 80.52% | ||
<!-- | Total: | 8 | --> |
Totals | |
---|---|
Change from base Build 6e7ee6fa-6a5e-4c8b-b873-e06b32984d79: | -0.05% |
Covered Lines: | 12067 |
Relevant Lines: | 16978 |
Currently, a test workflow like this will not ever run the code after the goroutine's sleep, nor the code in the defer:
The workflow will correctly end, but since the dispatcher was never closed, any not-yet-complete goroutines would never exit, and we'd leak goroutines.
Semantically this should be a safe change:
So safe / correct code should be unaffected, leaks should be reduced, and latent mistakes should now cause errors. AFAICT - I'm not sure how complete our tests are here :)
There's some room for in-defer code to be semantically incorrect in tests without this fix, (e.g. testing custom logger/metric impls in defers), though I expect those to be very rare bordering on nonexistent. But for the most part I expect that people will not notice this change, they'll just have fewer goroutine leaks during tests (so e.g. https://github.com/uber-go/goleak users will be happy).
Prior to this fix, the added test fails with:
Now it passes with this, which also shows it's not slowing tests down in any meaningful way: