Skip to content

Commit cfb850e

Browse files
committed
fix(prt): suppress spurious context canceled errors during shutdown
1 parent c5610db commit cfb850e

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

internal/prt/service.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,18 @@ func (s *Service) Reload() []error { return nil }
128128
// Tick executes the Validator main logic of producing claims and/or proofs
129129
// for processed epochs of all running applications.
130130
func (s *Service) Tick() []error {
131+
// Check for shutdown before starting work, consistent with the advancer.
132+
if s.IsStopping() {
133+
return nil
134+
}
135+
131136
apps, _, err := getAllRunningApplications(s.Context, s.repository)
132137
if err != nil {
138+
// Only suppress context errors during shutdown; surface real DB errors.
139+
if s.IsStopping() && errors.Is(err, context.Canceled) {
140+
s.Logger.Warn("Tick interrupted by shutdown", "error", err)
141+
return nil
142+
}
133143
return []error{fmt.Errorf("failed to get running applications. %w", err)}
134144
}
135145

@@ -140,15 +150,20 @@ func (s *Service) Tick() []error {
140150
return errs
141151
}
142152
if err := s.validateApplication(s.Context, apps[idx]); err != nil {
153+
// During shutdown, in-flight L1 requests see context cancellation.
154+
// Suppress these to avoid spurious ERR log entries.
155+
if s.IsStopping() && errors.Is(err, context.Canceled) {
156+
s.Logger.Warn("Tick interrupted by shutdown",
157+
"application", apps[idx].IApplicationAddress, "error", err)
158+
continue
159+
}
143160
errs = append(errs, err)
144161
}
145162
}
146163
return errs
147164
}
148165

149-
func (s *Service) Stop(_ bool) []error {
150-
return nil
151-
}
166+
func (s *Service) Stop(_ bool) []error { return nil }
152167

153168
func (s *Service) String() string {
154169
return s.Name

0 commit comments

Comments
 (0)