• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Dravere · Feb 10, 2019 at 03:07 PM · exceptionasyncvoidconsole errorsrepeating

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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by thomh_unity · Mar 05, 2019 at 10:02 AM

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

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Dravere · Mar 05, 2019 at 03:21 PM 0
Share

Thank you very much for the answer. Wasn't expecting one after all this time. And yes, 2018.3.2 fixes the problem! It is not exactly a serious problem but at times quite an annoying one.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

99 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to make a file run if a void has undefined coordinates? 1 Answer

using void OnTriggerExit get error...Here is Script screen shot 1 Answer

Make message to other gameObject stop. 1 Answer

get component screws with the game. 2 Answers

The console no longer takes you directly to the error in the script? 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges