MCPcopy Create free account
hub / github.com/docker/docker-agent / safeInstall

Function safeInstall

pkg/toolinstall/resolver.go:84–94  ·  view source on GitHub ↗

safeInstall wraps install with panic recovery. Without this, singleflight wraps any panic in *panicError and re-raises it via `go panic(...)` (see golang.org/x/sync/singleflight), which is unrecoverable by callers and crashes the process. Issue #2765.

(ctx context.Context, command, version string, install installFunc)

Source from the content-addressed store, hash-verified

82// `go panic(...)` (see golang.org/x/sync/singleflight), which is
83// unrecoverable by callers and crashes the process. Issue #2765.
84func safeInstall(ctx context.Context, command, version string, install installFunc) (path string, err error) {
85 defer func() {
86 if r := recover(); r != nil {
87 slog.ErrorContext(ctx, "Panic during tool auto-install",
88 "command", command, "panic", r, "stack", string(debug.Stack()))
89 path = ""
90 err = fmt.Errorf("auto-install for %q panicked: %v", command, r)
91 }
92 }()
93 return install(ctx, command, version)
94}
95
96// doInstall performs the actual package resolution and installation.
97func doInstall(ctx context.Context, command, versionRef string) (string, error) {

Callers 3

resolveFunction · 0.85

Calls

no outgoing calls