Skip to content

Commit

Permalink
When a request fails it will no longer be written to the console. Thi…
Browse files Browse the repository at this point in the history
…s causes a lot of spam, and can be confusing to users as quite frequently these errors are just transient.

SteamPrefill will now batch log these errors at the end of a download attempt, when the requests have failed 3 times each.
  • Loading branch information
tpill90 committed Mar 2, 2024
1 parent 4e240f9 commit 15b56a2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
18 changes: 13 additions & 5 deletions SteamPrefill/Handlers/DownloadHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ await _ansiConsole.CreateSpectreProgress(downloadArgs.TransferSpeedUnit).StartAs
while (failedRequests.Any() && retryCount < 2)
{
retryCount++;
await Task.Delay(2000 * retryCount);
failedRequests = await AttemptDownloadAsync(ctx, $"Retrying {retryCount}..", failedRequests.ToList(), downloadArgs, forceRecache: true);
}
});
Expand All @@ -60,15 +59,25 @@ await _ansiConsole.CreateSpectreProgress(downloadArgs.TransferSpeedUnit).StartAs
return true;
}

_ansiConsole.MarkupLine(Red($"{failedRequests.Count} failed downloads"));
_ansiConsole.LogMarkupError($"Download failed! {LightYellow(failedRequests.Count)} requests failed unexpectedly, see {LightYellow("app.log")} for more details.");
_ansiConsole.WriteLine();

// Web requests frequently fail due to transient errors, so displaying all errors to the user is unnecessary or even confusing.
// However, if a request fails repeatedly then there might be an underlying issue preventing success.
// The number of failures could approach in the thousands or even more, so rather than spam the console
// we will instead log them as a batch to app.log
foreach (var failedRequest in failedRequests)
{
FileLogger.LogExceptionNoStackTrace($"Request /depot/{failedRequest.DepotId}/chunk/{failedRequest.ChunkId} failed", failedRequest.LastFailureReason);
}
return false;
}

//TODO I don't like the number of parameters here, should maybe rethink the way this is written.
/// <summary>
/// Attempts to download the specified requests. Returns a list of any requests that have failed for any reason.
/// </summary>
/// <param name="forceRecache">When specified, will cause the cache to delete the existing cached data for a request, and redownload it again.</param>
/// <param name="forceRecache">When specified, will cause the cache to delete the existing cached data for a request, and re-download it again.</param>
/// <returns>A list of failed requests</returns>
public async Task<ConcurrentBag<QueuedRequest>> AttemptDownloadAsync(ProgressContext ctx, string taskTitle, List<QueuedRequest> requestsToDownload,
DownloadArguments downloadArgs, bool forceRecache = false)
Expand Down Expand Up @@ -104,9 +113,8 @@ public async Task<ConcurrentBag<QueuedRequest>> AttemptDownloadAsync(ProgressCon
}
catch (Exception e)
{
request.LastFailureReason = e;
failedRequests.Add(request);
_ansiConsole.LogMarkupLine(Red($"Request /depot/{request.DepotId}/chunk/{request.ChunkId} failed : {e.GetType()}"));
FileLogger.LogExceptionNoStackTrace($"Request /depot/{request.DepotId}/chunk/{request.ChunkId} failed", e);
}
progressTask.Increment(request.CompressedLength);
});
Expand Down
2 changes: 2 additions & 0 deletions SteamPrefill/Models/QueuedRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public struct QueuedRequest
[ProtoMember(3)]
public readonly uint CompressedLength;

public Exception LastFailureReason { get; set; }

public QueuedRequest(Manifest depotManifest, ChunkData chunk)
{
DepotId = depotManifest.DepotId;
Expand Down
2 changes: 1 addition & 1 deletion SteamPrefill/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"Benchmark - Setup - Preset": {
"commandName": "Project",
"commandLineArgs": "benchmark setup -h"
"commandLineArgs": "benchmark setup --preset SmallChunks"
},
"Benchmark - Setup - All": {
"commandName": "Project",
Expand Down

0 comments on commit 15b56a2

Please sign in to comment.