I’ve facing this issue too, on nested races regardless of being on different functions or not. It caused some issues on a project until I discovered that this was the cause of my code not working as expected.
This bug report correlates with this one: Defer does not always run in specific scenarios