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.

Scoped Dependency Issue

See original GitHub issue

This issue may prove tricky to repro, so I’ll explain the issue and you can advise on further action.

This image shows some logs containing the HttpContext TraceIdentifier, the DbContext Id and a Guid in a scoped dependency RequestAuthVariables.


The highlighted rows show that two different HttpContexts get the same instance of RequestAuthVariables.

This is an intermittent issue in our production system and we’ve been able to reproduce in an integration test using a Parallel.ForEachAsync loop of 100. A loop of 10 typically works correctly and even the loop of 100 occasionally works.

Our interim solution is to register our triggers as Transient instead of Scoped.

We’re using the AddTriggeredDbContextPool and AddTriggeredPooledDbContextFactory

@benmccallum and I are happy to try and work with you as needed.

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:2
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

anthony-kellercommented, Dec 12, 2022

I did report a potential regression on the pr about 30 mins ago

stale[bot]commented, Aug 18, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use scoped services within a BackgroundService - .NET
Resolve scoped dependencies in a singleton BackgroundService. Delegate work to a scoped service. Implement an override of BackgroundService.
Read more >
Middleware-scoped service dependency issue #1327
In one occurrance of this issue, that class is registered as scoped, in other, it is injected directly into Azure Function. It is...
Read more >
Dependency injection in ASP.NET Core
The framework creates a scope per request, and RequestServices exposes the scoped service provider. All scoped services are valid for as long ...
Read more >
The dangers and gotchas of using scoped services in ...
As we've registered our IConfigureOptions<> as a Scoped service, we have a captive dependency problem, so in the Development environment, ASP.
Read more >
C# Dependency Injection Cannot Consume Scoped?
Scoped services are created once per request. This means, when a scoped service is instantiated, it stays alive until the end of the...
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 Post

No results found

github_iconTop Related Hashnode Post

No results found