discord-net / Discord.Net

An unofficial .Net wrapper for the Discord API (https://discord.com/)
https://discordnet.dev
MIT License
3.28k stars 743 forks source link

[Bug]: A task is cancelled error after the bot has disconnected #2679

Open JoshuaMaitland opened 1 year ago

JoshuaMaitland commented 1 year ago

Check The Docs

Verify Issue Source

I've been updated the latest version of Discord.Net and when I connect the bot, it's working fine. But when I click on disconnect button (bear in mind that I'm doing this on WinForms in C#) and this error came up like this. (see logs) This issue seems to be doing this on versions that is higher than 3.9

Version

Version that is higher than 3.9

Working Version

No response

Logs

20:15:12 Discord Discord.Net v3.10.0 (API v10) 20:15:13 Gateway Connecting 20:15:14 Gateway Connected 20:15:15 Gateway Ready 20:15:22 Gateway System.Threading.Tasks.TaskCanceledException: A task was canceled. at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Discord.ConnectionManager.<>cDisplayClass29_0.<b0>d.MoveNext() 20:15:22 Gateway Disconnecting 20:15:22 Gateway Disconnected

Sample

No response

Packages

Discord.Net.Commands v3.10.0 Discord.Net.Core v3.10.0 Discord.Net.Interactions v3.10.0 Discord.Net.Rest v3.10.0 Discord.Net.Webhook v3.10.0 Discord.Net.WebSocket v3.10.0 MySql.Data v6.10.9 Newtonsoft.Json v13.0.3

JoshuaMaitland commented 1 year ago

Still the same issue after upgrading to v3.11.0 DiscordNet311TestConsole_2023-07-05_20-38-50

Misha-133 commented 1 year ago

Idk if this will ever get fixed (at least until v4) Just to give some backstory: https://github.com/discord-net/Discord.Net/blob/dev/src/Discord.Net.WebSocket/ConnectionManager.cs#L81-L89

JoshuaMaitland commented 9 months ago

Idk if this will ever get fixed (at least until v4) Just to give some backstory: https://github.com/discord-net/Discord.Net/blob/dev/src/Discord.Net.WebSocket/ConnectionManager.cs#L81-L89

Right, I think that might be the reason why though. Because when I was using v3.9 it doesn't print the TaskCanceledException error whilst with v3.10 or later, it does printed out a error.

JoshuaMaitland commented 7 months ago

Still the same issue on v3.13.0

DiscordNetTestConsole_2024-01-06_12-34-28

JoshuaMaitland commented 3 months ago

One year since I've opened this issue, but it's still hasn't fixed. Still happened on v3.15.0 (latest, at the time of writing to this comment)

DiscordNetTestConsole_2024-05-15_20-34-13

Quantam-Studios commented 3 months ago

Idk if this will ever get fixed (at least until v4) Just to give some backstory: https://github.com/discord-net/Discord.Net/blob/dev/src/Discord.Net.WebSocket/ConnectionManager.cs#L81-L89

v4 still is not out.

JoshuaMaitland commented 3 months ago

Idk if this will ever get fixed (at least until v4) Just to give some backstory: https://github.com/discord-net/Discord.Net/blob/dev/src/Discord.Net.WebSocket/ConnectionManager.cs#L81-L89

v4 still is not out.

Exactly. I'm not too sure about v4. I'm way concerned about this. Maybe it could be the change of .NET Framework or something.