Add timeout to debug bundle upload on Android

Use a 2-minute context timeout instead of context.Background()
to prevent the upload from blocking indefinitely.
This commit is contained in:
Zoltán Papp
2026-04-14 19:52:07 +02:00
parent a35ecf9aa8
commit f01c1eea6a

View File

@@ -8,6 +8,7 @@ import (
"os" "os"
"slices" "slices"
"sync" "sync"
"time"
"golang.org/x/exp/maps" "golang.org/x/exp/maps"
@@ -251,7 +252,10 @@ func (c *Client) DebugBundle(platformFiles PlatformFiles, anonymize bool) (strin
} }
}() }()
key, err := debug.UploadDebugBundle(context.Background(), types.DefaultBundleURL, cfg.ManagementURL.String(), path) uploadCtx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
defer cancel()
key, err := debug.UploadDebugBundle(uploadCtx, types.DefaultBundleURL, cfg.ManagementURL.String(), path)
if err != nil { if err != nil {
return "", fmt.Errorf("upload debug bundle: %w", err) return "", fmt.Errorf("upload debug bundle: %w", err)
} }