FlurlCall.Succeeded should null-check response, not request
See original GitHub issueAfter upgrading Flurl 2.x to 3.0 some tests fail.
I identified the issue, it seems to be related to the SimulateTimeout. If I call SimulateTimeout and not add a RespondWith after, all next calls will throw FlurlHttpTimeoutException, that was not the case with Flurl 2.x.
Some tests (XUnit + Shouldly) to illustrate the issue.
[Fact]
public async Task TestOk()
{
FlurlClient flurlClient = new FlurlClient("http://fakeurl.io/api");
await Should.NotThrowAsync(async () => await flurlClient.Request().GetAsync());
}
[Fact]
public async Task TestTimeoutOk()
{
HttpTest.SimulateTimeout();
FlurlClient flurlClient = new FlurlClient("http://fakeurl.io/api");
await Should.ThrowAsync<FlurlHttpTimeoutException>(async () => await flurlClient.Request().GetAsync());
HttpTest.RespondWith();
await Should.NotThrowAsync(async () => await flurlClient.Request().GetAsync());
}
[Fact]
public async Task TestTimeoutKo()
{
HttpTest.SimulateTimeout();
FlurlClient flurlClient = new FlurlClient("http://fakeurl.io/api");
await Should.ThrowAsync<FlurlHttpTimeoutException>(async () => await flurlClient.Request().GetAsync());
await Should.NotThrowAsync(async () => await flurlClient.Request().GetAsync());
}
I tried to workaround the issue by calling RespondWith just after SimulateTimeout, this fixed most of the tests.
But I encountered another issue.
System.NullReferenceException Object reference not set to an instance of an object. at Flurl.Http.FlurlCall.get_Succeeded()
From the code : https://github.com/tmenier/Flurl/blob/ed1e7bdf41ca7ebc5928f24f94c71cdc6a351a62/src/Flurl.Http/FlurlCall.cs#L84
I think there is a typo, HttpRequestMessage need to be HttpResponseMessage
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Fixed & released in 3.0.1. Your work-around is no longer needed.
Thanks, but you did still catch a small bug at the end there so I’ll keep this open until that’s fixed/released.