Skip to content

Add safeties against exceptions in OnlineLookupCache#36282

Merged
bdach merged 2 commits intoppy:masterfrom
peppy:online-lookup-cache-exception-safety
Jan 9, 2026
Merged

Add safeties against exceptions in OnlineLookupCache#36282
bdach merged 2 commits intoppy:masterfrom
peppy:online-lookup-cache-exception-safety

Conversation

@peppy
Copy link
Copy Markdown
Member

@peppy peppy commented Jan 9, 2026

Noticed in passing that an exception inside a lookup would cause the cache to never work again, and also not report this in logs at all.

🙈

@peppy peppy added area:online functionality Deals with online fetching / sending but don't change much on a surface UI level. type/reliability Deals with game crashing or breaking in a serious way. labels Jan 9, 2026
@peppy peppy self-assigned this Jan 9, 2026
@peppy peppy moved this from Inbox to Pending Review in osu! team task tracker Jan 9, 2026
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 🤷


// 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.

@bdach bdach merged commit 2208209 into ppy:master Jan 9, 2026
7 of 9 checks passed
@github-project-automation github-project-automation bot moved this from Pending Review to Done in osu! team task tracker Jan 9, 2026
@peppy peppy deleted the online-lookup-cache-exception-safety branch January 13, 2026 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:online functionality Deals with online fetching / sending but don't change much on a surface UI level. size/S type/reliability Deals with game crashing or breaking in a serious way.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants