Skip to content
Merged
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
14 changes: 12 additions & 2 deletions osu.Game/Database/OnlineLookupCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Extensions;
using osu.Framework.Extensions.ExceptionExtensions;
using osu.Framework.Logging;
using osu.Game.Online.API;

namespace osu.Game.Database
Expand Down Expand Up @@ -81,7 +83,7 @@ public abstract partial class OnlineLookupCache<TLookup, TValue, TRequest> : Mem
pendingTasks.Enqueue((id, tcs));

// Create a request task if there's not already one.
if (pendingRequestTask == null)
if (pendingRequestTask == null || pendingRequestTask.IsFaulted)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could just clear the pending task in the OnlyOnFaulted continuation that was added anyway for logging purposes instead. No real preference here, maybe slightly nicer.

createNewTask();

return tcs.Task;
Expand Down Expand Up @@ -163,6 +165,14 @@ private void finishPendingTask()
}
}

private void createNewTask() => pendingRequestTask = Task.Run(performLookup);
private void createNewTask()
{
var nextTask = Task.Run(performLookup);
nextTask.ContinueWith(t =>
{
Logger.Error(t.Exception.AsSingular(), $"{nameof(OnlineLookupCache<TLookup, TValue, TRequest>)} lookup request failed!");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logger.Error() will post notifications. Combined with the fact that this cache batches requests in 50 per batch this will potentially get very noisy, and people with bad connections already scream at us for spamming notifications.

I'd recommend switching to

Suggested change
Logger.Error(t.Exception.AsSingular(), $"{nameof(OnlineLookupCache<TLookup, TValue, TRequest>)} lookup request failed!");
Logger.Log($@"{nameof(OnlineLookupCache<TLookup, TValue, TRequest>)} lookup request failed!:\n{t.Exception.AsSingular()}", LoggingTarget.Network);

Copy link
Copy Markdown
Member Author

@peppy peppy Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did check on this and they are debounced, also won't be fired in case of an actual network error (LUCKILY, else this would be game over for most users), see:

catch (Exception e)
{
// todo: fix exception handling
request.Fail(e);
}

Felt like something we probably want to fire to sentry, but can alter if you disagree.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe fine then, not sure 🤷

}, TaskContinuationOptions.OnlyOnFaulted);
pendingRequestTask = nextTask;
}
}
}
Loading