Skip to content

Commit 6e4dc04

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 9a95aca commit 6e4dc04

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
@@ -706,12 +706,18 @@ func (extraction *Extraction) extractPackage(pkg *packages.Package) {
706706
extraction.WaitGroup.Add(1)
707707
extraction.GoroutineSem.acquire(1)
708708
go func(astFile *ast.File) {
709+
defer func() {
710+
if r := recover(); r != nil {
711+
log.Printf("Panic during file extraction in package %s: %v", pkg.PkgPath, r)
712+
}
713+
extraction.GoroutineSem.release(1)
714+
extraction.WaitGroup.Done()
715+
}()
716+
709717
err := extraction.extractFile(astFile, pkg)
710718
if err != nil {
711-
log.Fatal(err)
719+
log.Printf("Error extracting file in package %s: %v", pkg.PkgPath, err)
712720
}
713-
extraction.GoroutineSem.release(1)
714-
extraction.WaitGroup.Done()
715721
}(astFile)
716722
}
717723
}

0 commit comments

Comments
 (0)