Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[External - Refit/Fusillade] Cannot access a disposed object. Object name: 'System.Net.Http.HttpConnection+HttpConnectionResponseContent'. #6

Closed
dorisoy opened this issue Feb 2, 2021 · 4 comments

Comments

@dorisoy
Copy link

dorisoy commented Feb 2, 2021

Hi, @JeremyBP ,I use Apizr 1.9.0,I have an API request "GetPermissionRecordSettingAsync",when I try to send the same content twice (in case of timeout or similar), I get an "ObjectDisposedException" as follows:

[Get("/auth/user/permission/{userId}")] Task<APIResult<IList<PermissionRecordQuery>>> GetPermissionRecordSettingAsync([CacheKey] int store, int userId, CancellationToken calToken = default);

"exception": { "type": "Apizr.ApizrException1[[DCMS.Client.Services.APIResult1[[System.Collections.Generic.IList1[[DCMS.Client.Models.Users.PermissionRecordQuery, DCMS.Client, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null]], mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], DCMS.Client, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null]]",
"message": "Cannot access a disposed object.\nObject name: 'System.Net.Http.HttpConnection+HttpConnectionResponseContent'.",
"stackTrace": " at Apizr.ApizrManager1[TWebApi].ExecuteAsync[TResult] (System.Linq.Expressions.Expression1[TDelegate] executeApiMethod, System.Threading.CancellationToken cancellationToken, Fusillade.Priority priority) [0x005e4] in :0 \n at DCMS.Client.Services.UserService.GetPermissionRecordSettingAsync (System.Action1[T] action, System.Threading.CancellationTokenSource cts) [0x0013c] in <c6379d2ab81547ef80e263b722f90018>:0 ", "innerExceptions": [ { "type": "System.ObjectDisposedException", "message": "Cannot access a disposed object.\nObject name: 'System.Net.Http.HttpConnection+HttpConnectionResponseContent'.", "stackTrace": " at System.Net.Http.HttpContent.CheckDisposed () [0x00013] in <92d3ef97a77047c9ab125ae979975a02>:0 \n at System.Net.Http.HttpContent.ReadAsStreamAsync () [0x00000] in <92d3ef97a77047c9ab125ae979975a02>:0 \n at Refit.NewtonsoftJsonContentSerializer.DeserializeAsync[T] (System.Net.Http.HttpContent content) [0x00027] in <ea3d892ff3f046868a691cc71dcbabbf>:0 \n at Refit.RequestBuilderImplementation.DeserializeContentAsync[T] (System.Net.Http.HttpResponseMessage resp, System.Net.Http.HttpContent content) [0x002d5] in <ea3d892ff3f046868a691cc71dcbabbf>:0 \n at Refit.RequestBuilderImplementation+<>c__DisplayClass14_02[T,TBody].b__0 (System.Net.Http.HttpClient client, System.Threading.CancellationToken ct, System.Object[] paramList) [0x003a5] in :0 \n at Apizr.ApizrManager1[TWebApi].ExecuteAsync[TResult] (System.Linq.Expressions.Expression1[TDelegate] executeApiMethod, System.Threading.CancellationToken cancellationToken, Fusillade.Priority priority) [0x00528] in :0 ",
"wrapperSdkName": "appcenter.xamarin"
}
],
"wrapperSdkName": "appcenter.xamarin"
}`

@JeremyBP
Copy link
Contributor

JeremyBP commented Feb 2, 2021

Hi @dorisoy, yeah I noticed that and can repro this bug now.
Will try to fix it this week.
Thanks for reporting it.

@JeremyBP
Copy link
Contributor

JeremyBP commented Feb 2, 2021

Could you please try to turn off Fusillade priority management feature (activated by default) from the WebApiAttribute or the fluent api?
I wonder if it pass or fails on your side.
It seems to be related to Refit while used with Fusillade.
Actually I can reproduce the bug playing directly with Refit and Fusillade together (no Apizr at all) and I can find issues on GitHub talking about this bug #460 (closed but not fixed).
I'm considering opening an issue on Refit repo and link it to this place.

On the other hand I'm currently working on Apizr v3.0-beta1 witch will outsource all Fusillade code from the core package to a dedicated integration one called Apizr.Integrations.Fusillade.
As v3.0 will based on Refit v6 witch is currently in beta mode, I'll publish it into the pre-release channel. Also, Refit v6 introduce some breaking changes and Apizr v3 some to. I'll update the changelog when ready.

@JeremyBP JeremyBP changed the title Cannot access a disposed object. Object name: 'System.Net.Http.HttpConnection+HttpConnectionResponseContent'. [External - Refit] Cannot access a disposed object. Object name: 'System.Net.Http.HttpConnection+HttpConnectionResponseContent'. Feb 2, 2021
@JeremyBP
Copy link
Contributor

JeremyBP commented Feb 2, 2021

Here is the issue opened on the Refit side #1048 and here on the Fusillade side #148

@dorisoy
Copy link
Author

dorisoy commented Feb 2, 2021

Could you please try to turn off Fusillade priority management feature (activated by default) from the WebApiAttribute or the fluent api?
I wonder if it pass or fails on your side.
It seems to be related to Refit while used with Fusillade.
Actually I can reproduce the bug playing directly with Refit and Fusillade together (no Apizr at all) and I can find issues on GitHub talking about this bug #460 (closed but not fixed).
I'm considering opening an issue on Refit repo and link it to this place.

On the other hand I'm currently working on Apizr v3.0-beta1 witch will outsource all Fusillade code from the core package to a dedicated integration one called Apizr.Integrations.Fusillade.
As v3.0 will based on Refit v6 witch is currently in beta mode, I'll publish it into the pre-release channel. Also, Refit v6 introduce some breaking changes and Apizr v3 some to. I'll update the changelog when ready.

👍👍👍 Thank you for your timely reply, I will use your guidance!

@JeremyBP JeremyBP changed the title [External - Refit] Cannot access a disposed object. Object name: 'System.Net.Http.HttpConnection+HttpConnectionResponseContent'. [External - Refit/Fusillade] Cannot access a disposed object. Object name: 'System.Net.Http.HttpConnection+HttpConnectionResponseContent'. Feb 2, 2021
@dorisoy dorisoy closed this as completed Jan 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants