Copied to clipboard

Flag this post as spam?

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

  • Alexander 23 posts 73 karma points
    Sep 13, 2019 @ 05:23

    Umbraco 8 Component ContentService.Published Async Action Kills IIS


    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 767 posts 2264 karma points c-trib
    Sep 13, 2019 @ 16:46

    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: