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)
| 82 | // `go panic(...)` (see golang.org/x/sync/singleflight), which is |
| 83 | // unrecoverable by callers and crashes the process. Issue #2765. |
| 84 | func 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. |
| 97 | func doInstall(ctx context.Context, command, versionRef string) (string, error) { |
no outgoing calls