ShopifySharp icon indicating copy to clipboard operation
ShopifySharp copied to clipboard

service.GetAsync causes EF db context to be disposed

Open zxed opened this issue 2 years ago • 5 comments

Running into a strange issue

I'm using EF + Sql with Dependency Injection in an azure functions project; just added ShopifySharp and noticed that after calling something like var customer = await service.GetAsync the db context is disposed....

I have no idea why this would be the case, or what I need to look at any thoughts on what I could look at to trouble shoot this?

zxed avatar May 27 '22 16:05 zxed

I was able to dig into this a bit deeper and using restsharp causes the same behaviour.

I swapped it out for WebClient and this doesn't cause the context to be disposed of.

It seems like the single context around HttpWebRequest maybe causes some of this? esp when used with DI and azure functions.

zxed avatar May 27 '22 19:05 zxed

Thanks for digging in! I’m at a wedding tonight and tomorrow but once I’m back I’ll be working on this library. I’ll take a look as soon as possible!

-- Josh Harms

On Fri, May 27, 2022, at 14:08, zxed wrote:

I was able to dig into this a bit deeper and using restsharp causes the same behaviour.

I swapped it out for WebClient and this doesn't cause the context to be disposed of.

It seems like the single context around HttpWebRequest maybe causes some of this? esp when used with DI and azure functions.

— Reply to this email directly, view it on GitHub https://github.com/nozzlegear/ShopifySharp/issues/744#issuecomment-1139953658, or unsubscribe https://github.com/notifications/unsubscribe-auth/AASOE7A4QFALIPNYHL6L6R3VMEMS5ANCNFSM5XEUF6LA. You are receiving this because you are subscribed to this thread.Message ID: @.***>

nozzlegear avatar May 28 '22 03:05 nozzlegear

@zxed Did you manage to work around this? We've had other reports about things behaving strangely in Azure Functions. I don't use it though, so I'm unclear where to start debugging.

nozzlegear avatar Jun 02 '22 20:06 nozzlegear

Intermittently - yesterday I went ahead and made sure all my async’s were awaited as someone said that this could be an issue.

It isn’t just this lib though - sendgrid api caused the same issue…. So I’m thinking maybe it is the async callers…. Will known soon in the next few days.

Zee

On Thu, Jun 2, 2022 at 4:22 PM Joshua Harms @.***> wrote:

@zxed https://github.com/zxed Did you manage to work around this? We've had other reports about things behaving strangely in Azure Functions. I don't use it though, so I'm unclear where to start debugging.

— Reply to this email directly, view it on GitHub https://github.com/nozzlegear/ShopifySharp/issues/744#issuecomment-1145305639, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABF6VWFQOXFA36RVSN4IY6LVNEJZRANCNFSM5XEUF6LA . You are receiving this because you were mentioned.Message ID: @.***>

zxed avatar Jun 02 '22 20:06 zxed

It looks like this is not just limited to azure functions.

I have a core .net API project that uses DI + entity framework for dbcontext.

After calling the Metafield service - the next call to SaveChanges (db context) results in an error, before calling metafield, it's all fine.

Makes zero sense.

On Thu, Jun 2, 2022 at 4:32 PM Zeeshan Sheikh @.***> wrote:

Intermittently - yesterday I went ahead and made sure all my async’s were awaited as someone said that this could be an issue.

It isn’t just this lib though - sendgrid api caused the same issue…. So I’m thinking maybe it is the async callers…. Will known soon in the next few days.

Zee

On Thu, Jun 2, 2022 at 4:22 PM Joshua Harms @.***> wrote:

@zxed https://github.com/zxed Did you manage to work around this? We've had other reports about things behaving strangely in Azure Functions. I don't use it though, so I'm unclear where to start debugging.

— Reply to this email directly, view it on GitHub https://github.com/nozzlegear/ShopifySharp/issues/744#issuecomment-1145305639, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABF6VWFQOXFA36RVSN4IY6LVNEJZRANCNFSM5XEUF6LA . You are receiving this because you were mentioned.Message ID: @.***>

zxed avatar Jun 09 '22 15:06 zxed

Thanks for looking into it! I'm going to close this because it sounds like an issue somewhere outside of this package. If I'm wrong please let me know and I'll reopen!

nozzlegear avatar Aug 15 '22 19:08 nozzlegear