Whilst trying to make a reproduceable example I discovered a .GetAwaiter().GetResult()
back in the calling code that seemed to be creating a deadlock only in the scenario I described in my question. Replacing this with an async function solved the issue.