question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

System.ObjectDisposedException: The semaphore has been disposed.

See original GitHub issue

Hello,

I am using the latest pre release version 2.0.0-beta 4 with aspnet core 3. During the execution of my production code I get a lot off errors from the Sentry client itself.

This is the output of the log.

fail: Sentry.ISentryClient[0]
      An error occured when capturing the event System.ObjectDisposedException: The semaphore has been disposed.
         at System.Threading.SemaphoreSlim.CheckDispose()
         at System.Threading.SemaphoreSlim.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
         at System.Threading.SemaphoreSlim.Wait(TimeSpan timeout)
         at Sentry.Internal.BackgroundWorker.EnqueueEvent(SentryEvent event)
         at Sentry.SentryClient.DoSendEvent(SentryEvent event, Scope scope)
         at Sentry.SentryClient.CaptureEvent(SentryEvent event, Scope scope).

Has anyone an idea what causes this? Thanks!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
bruno-garciacommented, Oct 27, 2019

I’ve pushed a fix and will release it as 2.0.0-beta5 once zeus.ci gets back online. Tomorrow it should be up. Thank y’all for raising this.

1reaction
artyomturkincommented, Oct 14, 2019

Same problem

  • “Sentry.AspNetCore” Version=“1.2.0”
  • Runtime: Asp.Net Core 2.2
fail: Sentry.ISentryClient[0]
      An error occured when capturing the event System.ObjectDisposedException: The semaphore has been disposed.
         at System.Threading.SemaphoreSlim.CheckDispose()
         at System.Threading.SemaphoreSlim.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
         at System.Threading.SemaphoreSlim.Wait(TimeSpan timeout)
         at Sentry.Internal.BackgroundWorker.EnqueueEvent(SentryEvent event)
         at Sentry.SentryClient.DoSendEvent(SentryEvent event, Scope scope)
         at Sentry.SentryClient.CaptureEvent(SentryEvent event, Scope scope).

Sentry is injected like this:

In Program.cs

public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .UseSentry()
                .UseStartup<Startup>();

And actual injection:

public class DefaultRequestHandler : IGCVPRequestsHandler
{
    private readonly DataflowBlocks _dataflowBlocks;
    private readonly IHub _sentry;

    public DefaultRequestHandler(DataflowBlocks dataflowBlocks, IHub sentry)
    {
        _dataflowBlocks = dataflowBlocks;
        _sentry = sentry;
    }
}

And called like:

_sentry.AddBreadcrumb("Hash checked", category: "checkwithHash", level: BreadcrumbLevel.Debug);

.........

_sentry.CaptureException(e);
Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - What is wrong in this code to throw an ...
It throws the following exception- System.ObjectDisposedException {"The semaphore has been disposed."} I have a class library like -
Read more >
Why my code is throwing `The semaphore has been disposed ...
ObjectDisposedException: 'The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.
Read more >
Best practice for handling async dispose using lock ...
I have run into an issue where I have a async method that disposes of resources asynchronously. This method needs to be multithreaded...
Read more >
DxChart for Blazor - "The semaphore has been disposed" ...
In our Blazor Server code we sometimes remove a chart from the markup interactively (we have a conditional that no longer shows the...
Read more >
You should be using using in CSharp - Lost in Details
Use using instead of calling Dispose() manually whenever you can to keep instances from escaping their dispose call. Refactor to reduce the need...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found