Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

timing issue between UnitOfWork and EntityCreatingEventHandler #11006


User avatar
0
sedulen created

Prerequisites

Please answer the following questions before submitting an issue.

  • What is your product version? v9.3.0
  • What is your product type (Angular or MVC)? Angular
  • What is product framework type (.net framework or .net core)? .net core

If issue related with ABP Framework

  • What is ABP Framework version? v5.14.0

I'm troubleshooting a real weird issue I'm having that seems to be environment related, but I'm not sure why it would be. I deploy using linux docker container images, and I've got a reseller now who's also deploying my application. I have a built docker image that I'm running in ~4 different environments (locally, hosted DEV, hosted UAT, and finally the reseller's hosted UAT)

Locally on my laptop, and in my 2 hosted environments, my app works great. In my reseller's hosted UAT environment, I'm seeing a really strange behavior where the UnitOfWork for the AppService method is Disposing before the EntityCreatingEventHandlers are done. I have logic in my AppService method that tries to optimize how a file is handled. The AppService medthod does some data manipulation using a Stream. When the EntityCreatingEventHandler fires, that file is posted to Azure Blob Storage. But to help keep the filesystem clean, I have attached to the UnitOfWork.Disposed event, where I delete the file from the filesystem.

Looking at my logfiles for where there are issues, the UnitOfWork is Disposing and deleting the file from the filesystem before my EntityCreatingEventHandler completes. I've been very careful to make sure all of my async/await calls are correct, so that I'm not forgetting to await an async call.

What's also very bizarre to me is that the same docker image w/ the same runtime ENV Var configuration would behave correctly in 3 environments, but incorrectly in this 4th environment.

Just to make sure I'm not misunderstanding how this is supposed to work, if I have IEventHandler or IAsyncEventHandler classes that attach to the EntityCreatingEventData<T>, that should execute before my UnitOfWork completes? Is this correct, or am I wrong here?

Thanks! -Brian


3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @sedulen

    Is it possible to share your AppService code with us ? Sharing only the problematic method might help as well.

  • User Avatar
    0
    sedulen created

    Hi @ismcagdas,

    Sure - let me see if I can get you a redacted copy of the code that I can share.

    I'll follow up in a day or two. -Brian

  • User Avatar
    0
    ismcagdas created
    Support Team

    Thanks.