Skip to content

Commit

Permalink
fix: prevent race with test exitCh
Browse files Browse the repository at this point in the history
Signed-off-by: Marko Kungla <marko@mkungla.dev>
  • Loading branch information
mkungla committed Jun 3, 2024
1 parent aad69a9 commit aeea8ba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion sdk/app/app-main.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,12 @@ func (m *Main) Run() {
m.init = nil
}

exitCh := m.rt.ExitCh()

go func() {
m.rt.Start()
}()
osmain(m.rt.ExitCh())
osmain(exitCh)
}

func (m *Main) Do(a action.WithArgs) *Main {
Expand Down
2 changes: 1 addition & 1 deletion sdk/app/internal/application/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ type ShutDown struct{}

// ExitCh return blocking channel that will reveive a signal when the runtime exits
func (rt *Runtime) ExitCh() <-chan ShutDown {
if testing.Testing() {
if testing.Testing() && rt.exitCh == nil {
rt.exitCh = make(chan ShutDown, 1)
}
return rt.exitCh
Expand Down

0 comments on commit aeea8ba

Please sign in to comment.