Skip to content

Commit

Permalink
Set timeouts of a minute for general package manager tasks, to preven…
Browse files Browse the repository at this point in the history
…t infinite loads (related to #1954)
  • Loading branch information
marticliment committed May 31, 2024
1 parent eed1e59 commit a615a8f
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public async Task<Package[]> FindPackages(string query)
if (!IsReady()) { Logger.Warn($"Manager {Name} is disabled but yet FindPackages was called"); return []; };
try
{
Package[] packages = await FindPackages_UnSafe(query);
Package[] packages = await FindPackages_UnSafe(query).WaitAsync(TimeSpan.FromSeconds(60));
for (int i = 0; i < packages.Length; i++)
{
packages[i] = PackageFactory.GetAvailablePackageIfRepeated(packages[i]);
Expand All @@ -174,8 +174,8 @@ public async Task<Package[]> GetAvailableUpdates()
if (!IsReady()) { Logger.Warn($"Manager {Name} is disabled but yet GetAvailableUpdates was called"); return []; };
try
{
await RefreshPackageIndexes();
Package[] packages = await GetAvailableUpdates_UnSafe();
await RefreshPackageIndexes().WaitAsync(TimeSpan.FromSeconds(60));
Package[] packages = await GetAvailableUpdates_UnSafe().WaitAsync(TimeSpan.FromSeconds(60));
for (int i = 0; i < packages.Length; i++)
packages[i] = PackageFactory.GetUpgradablePackageIfRepeated(packages[i]);
Logger.Info($"Found {packages.Length} available updates from {Name}");
Expand All @@ -199,7 +199,7 @@ public async Task<Package[]> GetInstalledPackages()
if (!IsReady()) { Logger.Warn($"Manager {Name} is disabled but yet GetInstalledPackages was called"); return []; };
try
{
Package[] packages = await GetInstalledPackages_UnSafe();
Package[] packages = await GetInstalledPackages_UnSafe().WaitAsync(TimeSpan.FromSeconds(60));
for (int i = 0; i < packages.Length; i++)
packages[i] = PackageFactory.GetInstalledPackageIfRepeated(packages[i]);
Logger.Info($"Found {packages.Length} installed packages from {Name}");
Expand Down Expand Up @@ -362,7 +362,7 @@ public virtual async Task<ManagerSource[]> GetSources()
try
{
AssertSourceCompatibility("GetSources");
var result = await SourceProvider.GetSources();
var result = await SourceProvider.GetSources().WaitAsync(TimeSpan.FromSeconds(60));
Logger.Debug($"Loaded {result.Length} sources for manager {Name}");
return result;
}
Expand Down

0 comments on commit a615a8f

Please sign in to comment.