-
Notifications
You must be signed in to change notification settings - Fork 37
Async/Await issue #54
Comments
I think you did run into a deadlock situation. You can read more about it here: https://blog.stephencleary.com/2012/07/dont-block-on-async-code.html Since you are working currently with this version of the Klarna SDK you should pass down the async context of your application the whole way down as mentioned in the article:
The other option is:
which is on us. So we would need to create a new release, but we are happy to receive a PR including the changes. There is also another blog article explaining the This is the code as it is right now in public async Task<OrderManagementOrder> GetOrder(string orderId)
{
var url = ApiUrlHelper.GetApiUrlForController(ApiSession.ApiUrl, ApiControllerUri, $"{orderId}");
var response = await Get<OrderManagementOrder>(url);
return response;
} But it should look like this: public async Task<OrderManagementOrder> GetOrder(string orderId)
{
var url = ApiUrlHelper.GetApiUrlForController(ApiSession.ApiUrl, ApiControllerUri, $"{orderId}");
return await Get<OrderManagementOrder>(url).ConfigureAwait(false);
} |
The fix is coming: #55 |
@igeligel added as a reviewer |
Merged. The changes will appear in the next release. |
Describe the bug
When using GetOrder the task never retruns. It can be fixed by adding .ConfigureAwait(false) when using async.
Async/Await - Best Practices in Asynchronous Programming
https://msdn.microsoft.com/en-us/magazine/jj991977.aspx
Which service do you use
Every call to klarna
To Reproduce
var klarnaEnv = isTest ? KlarnaEnvironment.TestingEurope : KlarnaEnvironment.LiveEurope;
var klarnaApi = new Klarna.Rest.Core.Klarna(username, password, klarnaEnv);
var task = klarnaApi.OrderManagement.GetOrder(klarnaOrderId);
task.Wait(TimeSpan.FromMinutes(1));
Expected behavior
Wait to terminate when order has been recieved
Additional context
The text was updated successfully, but these errors were encountered: