Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Alexander 21 posts 71 karma points
    6 days ago
    Alexander
    0

    Umbraco 8 Component ContentService.Published Async Action Kills IIS

    Hi,

    I'm running Umbraco 8. I have a quite simple scenario:

    1. Umbraco component is subscribed to ContentService.Published action and have some conditions.
    2. If conditions are true I need to send an email to the user. For emails, I'm using SendGrid, which is very common in our days. Sendgrid nuget package provides only async method to send an email. And it doesn't work when I call it from the ContentPublished event handler.
    3. Moreover, whatever async method I call from the event handler kills IIS with Async Lock error.

    In component initialize I have:

    ContentService.Published += OnPublishedPage;
    

    Handler code looks like this:

    // async doesn't work here and kills IIS
    var response = _emailSender.SendUserDownloadEmailAsync(members, tender).GetAwaiter().GetResult();
    

    Is there any workaround or could you please point me to the right direction?

    Thanks, Alexander.

  • Stephen 766 posts 2260 karma points hq
    5 days ago
    Stephen
    0

    Interesting. Can you ... try to replace whatever happens in SendUserDownloadEmailAsync by a simple await Task.Delay(100) and see whether it still causes the error?

    In which case, the error is narrowed down to the async call. Otherwise, it might have to do with Sendgrid.

    Now... do you have details about "the event handler kills IIS with Async Lock error" - is it the entire w3wp process that dies? Where do you see the error? In the Event Log or in Umbraco's log? Can we have the full details on the error?

    Suspecting some threading issue with the async call...

Please Sign in or register to post replies

Write your reply to:

Draft