How to prevent repeating exceptions in console for async void method?

If I attach the following MonoBehaviour to an active GameObject (e.g. Camera) and then start the application (play in Editor), I get an indefinitely repeating exception logging in the console of the Editor. I would expect that it would log the exception once and not continuously repeating it.

using System;
using System.Threading.Tasks;
using UnityEngine;

public class TestController
    : MonoBehaviour
{
    [SerializeField]
    private int m_counter;
    
    public async void TestIt()
    {
        if(m_counter > 0)
        {
            return;
        }
        
        await Task.Delay(1);
        ++m_counter;
        throw new Exception("Once");
    }
    
    private void Update()
    {
        TestIt();
    }
}

The field m_counter stays at 1. So no new exception is thrown. It doesn’t even stop when I stop playing the app. It will continue to spam the console in the Editor. I have to restart the Editor to stop it.

Can somebody explain to me why this is the case and how I can prevent it? I’m using the Unity Editor 2018.3.3f1 on Linux.

Hi Dravere,

It looks like you’ve run into this issue. We’re testing a fix for this at the moment and hope to have it released in a future version.

If this is a serious problem for you then you might consider using 2018.3.2 where this issue does not occur.

Thom

Unity Support