Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(vcs): improve timeout handling for vcs upgrade check #2120

Merged
merged 1 commit into from
Apr 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions pkg/upgrade/sources.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package upgrade

import (
"context"
"time"

"github.com/leonelquinteros/gotext"

Expand All @@ -22,10 +21,8 @@ func UpDevel(
toRemove := make([]string, 0)
toUpgrade := UpSlice{Up: make([]Upgrade, 0), Repos: []string{"devel"}}

ctxTimeout, cancel := context.WithTimeout(ctx, 20*time.Second)
defer cancel()
for pkgName, pkg := range remote {
if localCache.ToUpgrade(ctxTimeout, pkgName) {
if localCache.ToUpgrade(ctx, pkgName) {
if _, ok := aurdata[pkgName]; !ok {
log.Warnln(gotext.Get("ignoring package devel upgrade (no AUR info found):"), pkgName)
continue
Expand Down
4 changes: 3 additions & 1 deletion pkg/vcs/vcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
"github.com/Jguer/yay/v12/pkg/text"
)

const defaultTimeout = 15 * time.Second

type Store interface {
// ToUpgrade returns true if the package needs to be updated.
ToUpgrade(ctx context.Context, pkgName string) bool
Expand Down Expand Up @@ -82,7 +84,7 @@ func (v *InfoStore) getCommit(ctx context.Context, url, branch string, protocols
if len(protocols) > 0 {
protocol := protocols[len(protocols)-1]

ctxTimeout, cancel := context.WithTimeout(ctx, 10*time.Second)
ctxTimeout, cancel := context.WithTimeout(ctx, defaultTimeout)
defer cancel()

cmd := v.CmdBuilder.BuildGitCmd(ctxTimeout, "", "ls-remote", protocol+"://"+url, branch)
Expand Down