bugsnag/bugsnag-dotnet

Please provide way of waiting for background notification to complete

mikeparker opened this issue · 1 comments

I was surprised to learn that the Notify() call does not return a Task I can wait for completion on, and instead triggers the notification on a hidden background thread which can be accidentally cancelled if the program exits early.

Why is this a problem? Firstly because we need to insert manual delays into tests to give bugsnag .net time to complete:

        [Test, Ignore("This sends a real bugsnag report. Only used for manual testing so we don't spam the server")]
        public async Task TestNotifyAsync()
        {
 // .. setup

            bugsnag.Notify(new Exception("BugSnagUnitTest"));

            // BugSnag notifications are done on a background thread, give it time to complete
            await Task.Delay(2000);
        }

Second problem is that sometimes we get errors on our CI:

[10:50:57.056] [FileSystem] Retrying delete directory
[10:50:57.056] [FileSystem] Failed to delete
Exception type: System.UnauthorizedAccessException, Exception message: Access to the path 'Bugsnag.dll' is denied., StackTrace:
   at System.IO.Directory.DeleteHelper(String fullPath, String userPath, Boolean recursive, Boolean throwOnTopLevelDirectoryNotFound)
   at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive, Boolean checkHost)
   at CommunityInstaller.FileSystem.<Delete>d__2.MoveNext()

Possibly because of background tasks not completing in time.

Can we either get a Task returned or another method we can call to wait for the background uploads to complete?

Hi @mikeparker we do not have any plans to get notify() to return a task.
The DLL likely can't be deleted because the process which is using it hasn't terminated rather than because Bugsnag is still doing anything.