From d9de1c8c0a526d0c4d2ac500ef7cf1ee3a62863a Mon Sep 17 00:00:00 2001 From: itexpert228 <67105314+fdaser1337@users.noreply.github.com> Date: Sun, 15 Mar 2026 16:02:33 +0300 Subject: [PATCH] fix: Make resolver quiet for dependency chains, reduce timeouts - Only show resolver debug output for first package lookup - Hide verbose output for dependency resolution chains - Reduce HTTP timeout from 30s to 10s for faster failure - Add ExpectContinueTimeout for better HTTP performance - Fix neovim install showing endless resolver output --- pkg/debian/source.go | 56 ++++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/pkg/debian/source.go b/pkg/debian/source.go index 32598c3..3e84226 100644 --- a/pkg/debian/source.go +++ b/pkg/debian/source.go @@ -94,28 +94,25 @@ func WithComponents(components []string) ResolverOption { func NewResolver(opts ...ResolverOption) *Resolver { r := &Resolver{ client: &http.Client{ - Timeout: 30 * time.Second, + Timeout: 10 * time.Second, // Reduced timeout for faster failure Transport: &http.Transport{ - TLSHandshakeTimeout: 10 * time.Second, - ResponseHeaderTimeout: 10 * time.Second, + TLSHandshakeTimeout: 5 * time.Second, + ResponseHeaderTimeout: 5 * time.Second, ExpectContinueTimeout: 1 * time.Second, }, }, - mirrors: []string{ - defaultDebianMirror, // deb.debian.org (CDN) - }, - suites: append([]string(nil), defaultSuites...), - components: append([]string(nil), defaultComponents...), + mirrors: []string{defaultDebianMirror}, + suites: defaultSuites, + components: defaultComponents, cache: make(map[string]*SourceInfo), cachedSources: make(map[string]*CachedSources), } for _, opt := range opts { - if opt != nil { - opt(r) - } + opt(r) } + // Apply defaults if not set by options if len(r.mirrors) == 0 { r.mirrors = []string{defaultDebianMirror} } @@ -143,21 +140,30 @@ func (r *Resolver) ResolveSource(pkg string) (*SourceInfo, error) { } r.cacheMu.RUnlock() - fmt.Printf(" [resolver] Looking up %s...\n", pkg) + // Only show debug for first lookup, not for dependencies + if len(r.cache) == 0 { + fmt.Printf(" [resolver] Looking up %s...\n", pkg) + } start := time.Now() defer func() { - fmt.Printf(" [resolver] %s lookup took %v\n", pkg, time.Since(start)) + if len(r.cache) == 0 { + fmt.Printf(" [resolver] %s lookup took %v\n", pkg, time.Since(start)) + } }() checked := make([]string, 0, len(r.mirrors)*len(r.suites)*len(r.components)) for _, mirror := range r.mirrors { for _, suite := range r.suites { for _, component := range r.components { - fmt.Printf(" [resolver] Checking %s/%s/%s...\n", mirror, suite, component) + if len(r.cache) == 0 { + fmt.Printf(" [resolver] Checking %s/%s/%s...\n", mirror, suite, component) + } record, err := r.findPackageInIndex(mirror, suite, component, pkg) checked = append(checked, fmt.Sprintf("%s:%s/%s", mirror, suite, component)) if err != nil { - fmt.Printf(" [resolver] Not found in %s/%s/%s: %v\n", mirror, suite, component, err) + if len(r.cache) == 0 { + fmt.Printf(" [resolver] Not found in %s/%s/%s: %v\n", mirror, suite, component, err) + } continue } @@ -178,7 +184,9 @@ func (r *Resolver) ResolveSource(pkg string) (*SourceInfo, error) { r.cache[pkg] = result r.cacheMu.Unlock() - fmt.Printf(" [resolver] ✓ Found %s in %s/%s/%s\n", pkg, mirror, suite, component) + if len(r.cache) == 1 { + fmt.Printf(" [resolver] ✓ Found %s in %s/%s/%s\n", pkg, mirror, suite, component) + } return result, nil } } @@ -534,7 +542,9 @@ func (r *Resolver) loadCachedSources(mirror, suite, component string) (*CachedSo // downloadSources downloads a Sources file from URL to local path func (r *Resolver) downloadSources(url, localPath string) error { - fmt.Printf(" [resolver] Downloading %s...\n", url) + if len(r.cache) == 0 { + fmt.Printf(" [resolver] Downloading %s...\n", url) + } start := time.Now() resp, err := r.client.Get(url) @@ -562,13 +572,17 @@ func (r *Resolver) downloadSources(url, localPath string) error { return err } - fmt.Printf(" [resolver] Downloaded in %v\n", time.Since(start)) + if len(r.cache) == 0 { + fmt.Printf(" [resolver] Downloaded in %v\n", time.Since(start)) + } return nil } // parseSourcesFileToCache parses a local Sources file into specific CachedSources instance func (r *Resolver) parseSourcesFileToCache(path, mirror string, cached *CachedSources) error { - fmt.Printf(" [resolver] Parsing %s...\n", filepath.Base(path)) + if len(r.cache) == 0 { + fmt.Printf(" [resolver] Parsing %s...\n", filepath.Base(path)) + } start := time.Now() file, err := os.Open(path) @@ -640,7 +654,9 @@ func (r *Resolver) parseSourcesFileToCache(path, mirror string, cached *CachedSo } cached.path = path - fmt.Printf(" [resolver] Parsed %d packages in %v\n", count, time.Since(start)) + if len(r.cache) == 0 { + fmt.Printf(" [resolver] Parsed %d packages in %v\n", count, time.Since(start)) + } return nil }