From 0542e9a997b98b4fec4a2d2441adba2a1cf36210 Mon Sep 17 00:00:00 2001 From: Fabio Bonelli Date: Wed, 25 Jan 2023 15:36:33 +0100 Subject: [PATCH] feat: handle GitHub secondary rate limiting (#322) --- scanner/github.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scanner/github.go b/scanner/github.go index 2cb655e..de745f2 100644 --- a/scanner/github.go +++ b/scanner/github.go @@ -128,6 +128,11 @@ Retry: time.Sleep(time.Until(resp.Rate.Reset.Time)) goto Retry } + if _, ok := err.(*github.AbuseRateLimitError); ok { + log.Infof("GitHub secondary rate limit hit, sleeping until %s", resp.Rate.Reset.Time.String()) + time.Sleep(time.Until(resp.Rate.Reset.Time)) + goto Retry + } if err != nil { return fmt.Errorf("can't get repo %s: %w", url.String(), err) }