Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Cancel parent context when aborting bootstrapping
Signed-off-by: Yacov Manevich <[email protected]>
  • Loading branch information
yacovm committed Nov 25, 2025
commit 1dd67cb25a819e9b5a13a7d7f1bde711c4749cca
9 changes: 8 additions & 1 deletion chains/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ type manager struct {
// processed.
chainCreatorShutdownCh chan struct{}
chainCreatorExited sync.WaitGroup
context context.Context
cancelContext context.CancelFunc

chainsLock sync.Mutex
// Key: Chain's ID
Expand Down Expand Up @@ -324,7 +326,11 @@ func New(config *ManagerConfig) (Manager, error) {
return nil, err
}

ctx, cancelContext := context.WithCancel(context.Background())

return &manager{
context: ctx,
cancelContext: cancelContext,
Aliaser: ids.NewAliaser(),
ManagerConfig: *config,
chains: make(map[ids.ID]handler.Handler),
Expand Down Expand Up @@ -468,7 +474,7 @@ func (m *manager) createChain(chainParams ChainParameters) {

// Tell the chain to start processing messages.
// If the X, P, or C Chain panics, do not attempt to recover
chain.Handler.Start(context.TODO(), !m.CriticalChains.Contains(chainParams.ID))
chain.Handler.Start(m.context, !m.CriticalChains.Contains(chainParams.ID))
}

// Create a chain
Expand Down Expand Up @@ -1523,6 +1529,7 @@ func (m *manager) Shutdown() {
m.Log.Info("shutting down chain manager")
m.chainsQueue.Close()
close(m.chainCreatorShutdownCh)
m.cancelContext()
m.chainCreatorExited.Wait()
m.ManagerConfig.Router.Shutdown(context.TODO())
}
Expand Down
Loading