Skip to content

RateLimitException HTTP Response Content does not get saved #2407

@Ascyt

Description

@Ascyt

Summary

It seems to be impossible to retrieve the response content of a RateLimitException:

catch (RateLimitException ex)
{
    string contents = await ex.Response.Content.ReadAsStringAsync(); // will get stuck indefinitely
}

as D#+ seems to dispose of it before it gets thrown. This makes it impossible to retrieve important information, such as whether the rate limit is guild-specific or global or the retry_after property.

Other exceptions might be affected too, I don't know, I didn't check.

What version of the library are you using?

v5.0.0-nightly (make sure you are using the latest nightly!)

What .NET version are you using? Make sure to use the latest patch release for your major version.

.NET 9.0

Operating System

Docker (Windows 11)

Reproduction Steps

Do something to cause a RateLimitException and try using .Response.Content.ReadAsStringAsync(). It will get stuck at that line forever.

Trace Logs


Exceptions or other error messages

Anything else you'd like to share

Things like response headers work fine. It just fails for the content.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions