Skip to content

Commit

Permalink
chore: figure out what is going on with the panic
Browse files Browse the repository at this point in the history
diagnoses: #2845
  • Loading branch information
stuartwdouglas committed Sep 26, 2024
1 parent e7250c3 commit 76321c4
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions go-runtime/schema/extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"go/types"
"slices"
"strings"
"time"

"github.com/TBD54566975/golang-tools/go/analysis"
"github.com/TBD54566975/golang-tools/go/analysis/passes/inspect"
Expand Down Expand Up @@ -297,11 +298,33 @@ func analyzersWithDependencies() []*analysis.Analyzer {
//
// flattens Extractors (a list of lists) into a single list to provide as input for the checker
extractors := Extractors()
for i, extractorRound := range extractors {
for _, extractor := range extractorRound {
var beforeIndex []*analysis.Analyzer
var extractorRound []*analysis.Analyzer
var extractor *analysis.Analyzer
var i int
defer func() {
// This code is cursed, it randomly panics and I don't know why
// Lets recover from the panic and see what the actual state of the program is
// This is temporary and should be removed once the curse has been lifted
if r := recover(); r != nil {
fmt.Printf("Recovered from intermittent panic in analysers: %v\n", r)
fmt.Printf("i: %d\n", i)
fmt.Printf("extractor: %v\n", extractor)
fmt.Printf("extractors: %v\n", extractors)
fmt.Printf("extractorRound: %v\n", extractorRound)
fmt.Printf("beforeIndex: %v\n", beforeIndex)
time.Sleep(time.Second) // Make sure the output makes it before the crash
panic(r) // re-panic
}
}()

for i, extractorRound = range extractors {
for _, extractor = range extractorRound {
extractor.RunDespiteErrors = true
extractor.Requires = append(extractor.Requires, dependenciesBeforeIndex(i)...)
beforeIndex = dependenciesBeforeIndex(i)
extractor.Requires = append(extractor.Requires, beforeIndex...)
as = append(as, extractor)

}
}
return as
Expand Down

0 comments on commit 76321c4

Please sign in to comment.