Skip to content

Commit 9440984

Browse files
committed
Fix Go extractor silent failures and improve error recovery
The extractor was calling log.Fatal() when file extraction failed, causing the entire extraction process to terminate silently on the first error. This was particularly problematic for OOM errors which would only appear in build-tracer logs, not in the extractor output. Changes: - Replace log.Fatal() with log.Printf() to log errors without terminating - Add panic recovery in file extraction goroutines to catch OOM errors - Move cleanup (semaphore release, WaitGroup.Done) into defer block to ensure proper cleanup even when panics occur This allows extraction to continue processing remaining files when individual files fail, and ensures errors are visible in extractor logs.
1 parent 5d2ddbf commit 9440984

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

go/extractor/extractor.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -692,12 +692,18 @@ func (extraction *Extraction) extractPackage(pkg *packages.Package) {
692692
extraction.WaitGroup.Add(1)
693693
extraction.GoroutineSem.acquire(1)
694694
go func(astFile *ast.File) {
695+
defer func() {
696+
if r := recover(); r != nil {
697+
log.Printf("Panic during file extraction in package %s: %v", pkg.PkgPath, r)
698+
}
699+
extraction.GoroutineSem.release(1)
700+
extraction.WaitGroup.Done()
701+
}()
702+
695703
err := extraction.extractFile(astFile, pkg)
696704
if err != nil {
697-
log.Fatal(err)
705+
log.Printf("Error extracting file in package %s: %v", pkg.PkgPath, err)
698706
}
699-
extraction.GoroutineSem.release(1)
700-
extraction.WaitGroup.Done()
701707
}(astFile)
702708
}
703709
}

0 commit comments

Comments
 (0)