Race condition in DiscordApiClient.PrepareMessage
Created by: uwx
Summary
A race condition when loading message history when a guild's members are still loading causes (if I'm correct, which I rarely am) the Members collection to be modified while it's being accessed here: https://github.com/NaamloosDT/DSharpPlus/blob/a6e23d8d28b301905d1e2d46f608c7b40b12cf02/DSharpPlus/Net/DiscordApiClient.cs#L63-L67 This throws an InvalidOperationException that bubbles up to the callee.
Details
Ask WamWooWham!#5274 i guess
at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
at DSharpPlus.Net.DiscordApiClient.PrepareMessage(JToken msg_raw)
at DSharpPlus.Net.DiscordApiClient.<GetChannelMessagesAsync>d__43.MoveNext()
Steps to reproduce
- I'll get to it in a bit