samber / do

⚙️ A dependency injection toolkit based on Go 1.18+ Generics.
https://pkg.go.dev/github.com/samber/do
MIT License
1.71k stars 67 forks source link

V2: Bug in parallel shutdown #76

Open samber opened 2 months ago

samber commented 2 months ago

I'm opening an issue to investigate a bug from @GreyXor, shared in #45.

#

I have two services, Config and Event. Where Event is a dependency of Config.

type ConfigService struct {
    Event *event.Service
}

In my Config's shutdown method, I calling anEvent's method.

With v2.0.0-beta.3, it's working as expected because the actual reverse order is respected. With v2.0.0-beta.5, it's randomly not working because Event is randomly Shutdown before Config. (because of the async)

#

@GreyXor I was not able to replicate this bug. Can you write a demo?

FYI, I just added a commit to v2 for supporting shutdown on circular dependencies.

GreyXor commented 2 months ago

Hello, sorry but I cannot replicate it anymore. I rewrote my services, as i'm not doing like this anymore.

GreyXor commented 2 months ago

@samber I will try to redo-it with the next v2 release. (containing the commit for supporting shutdown on circular dependencies). :+1:

GreyXor commented 1 month ago

@samber it's normal between 2 run of my app; the shutdown order is not the same ?