Skip to content

[Bug]: RunAsync fails to disconnect properly from the gateway #248

@Kaoticz

Description

@Kaoticz

Description

DiscordGatewayClient.RunAsync() doesn't seem to be properly disconnecting from the gateway when its CancellationToken is cancelled.

According to the official documentation:

When you close the connection to the gateway with close code 1000 or 1001, your session will be invalidated and your bot will appear offline.

If you simply close the TCP connection or use a different close code, the session will remain active and timeout after a few minutes.

The latter seems to be always happening, no matter what.

Steps to Reproduce

Execute DiscordGatewayClient.RunAsync(), then cancel the CancellationToken passed to it.
RunAsync will stop running, but the bot will still show as online on Discord for a couple of minutes.

Expected Behavior

The bot shuts down and shows as offline on Discord.

Current Behavior

The bot shuts down, but still shows as online on Discord for a couple of minutes.

Library / Runtime Information

.NET: 6.0.110
Remora.Discord: 2022.49.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions