Skip to content

Commit

Permalink
fix(syncer): set timeout for head request
Browse files Browse the repository at this point in the history
  • Loading branch information
vgonkivs committed Jan 30, 2024
1 parent a5a9f28 commit 89c2b8f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion sync/sync_head.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ func (s *Syncer[H]) Head(ctx context.Context, _ ...header.HeadOption[H]) (H, err
return s.Head(ctx)
}
defer s.getter.Unlock()
netHead, err := s.getter.Head(ctx, header.WithTrustedHead[H](sbjHead))

reqCtx, cancel := context.WithTimeout(ctx, time.Second*2)
defer cancel()

netHead, err := s.getter.Head(reqCtx, header.WithTrustedHead[H](sbjHead))
if err != nil {
log.Warnw("failed to get recent head, returning current subjective", "sbjHead", sbjHead.Height(), "err", err)
return s.subjectiveHead(ctx)
Expand Down

0 comments on commit 89c2b8f

Please sign in to comment.