Add safeties against exceptions in OnlineLookupCache#36282
Conversation
| var nextTask = Task.Run(performLookup); | ||
| nextTask.ContinueWith(t => | ||
| { | ||
| Logger.Error(t.Exception.AsSingular(), $"{nameof(OnlineLookupCache<TLookup, TValue, TRequest>)} lookup request failed!"); |
There was a problem hiding this comment.
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
| 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); |
There was a problem hiding this comment.
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:
osu/osu.Game/Online/API/APIAccess.cs
Lines 371 to 375 in 8bb885a
Felt like something we probably want to fire to sentry, but can alter if you disagree.
|
|
||
| // Create a request task if there's not already one. | ||
| if (pendingRequestTask == null) | ||
| if (pendingRequestTask == null || pendingRequestTask.IsFaulted) |
There was a problem hiding this comment.
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.
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.
🙈