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.

StackOverFlow Exception from WebJobsBuilderExtensions while running Azure function locally

See original GitHub issue

I have written Azure function which is throwing StackOverFlow Exception in the below code from class WebJobsBuilderExtensions in the namespace ` Microsoft.Azure.WebJobs

services.TryAddEnumerable(ServiceDescriptor.Singleton<IHostedService, JobHostService>());

Here is my Startup.cs class

 ` [assembly: WebJobsStartup(typeof(Startup))]
   namespace FuncApp
  {
      public class Startup : IWebJobsStartup
      {
       public void Configure(IWebJobsBuilder builder)
       {
           var config = new ConfigurationBuilder()
             .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
           .AddEnvironmentVariables()
           .Build();

     builder.Services
        .AddSingleton<IConfiguration>(config)
        .AddSingleton(serviceProvider => serviceProvider)
        .AddLogging();
    }
  }
 } `

Repro steps

Reproduction steps

  1. Create an azure trigger function using Visual studio 2019 or 2022
  2. Add Startup class and add above code
  3. Run

Expected behavior

Azure function shall run without any exceptions

Actual behavior

Stackoverflow exception

Known workarounds

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kshyjucommented, Oct 17, 2022

@codemaker What happens when you comment out/remove .AddSingleton(serviceProvider => serviceProvider) ?

1reaction
ramya894commented, Oct 12, 2022

@codemaker We are able to reproduce the issue and getting the stack overflow exception, we will check with our next level team and update you with the solution. you can share us the function app name as below so that we check the system logs and reason for the exception. Sharing Your Function App name privately

Read more comments on GitHub >

github_iconTop Results From Across the Web

StackOverFlow Exception from WebJobsBuilderExtensions ...
I have written Azure function which is throwing StackOverFlow Exception in the below code from class WebJobsBuilderExtensions in the ...
Read more >
StackOverFlow Exception from WebJobsBuilderExtensions ...
Coding example for the question StackOverFlow Exception from WebJobsBuilderExtensions while running Azure function locally.
Read more >
StackOverflowException on local debugging environment ...
Description. Every so often (about 30-50% of the time) when I start up my Azure Durable Functions local debugging environment, I will receive ......
Read more >
Stackoverflow error comes when adding serviceProvider
I had Azure function which was written using .NET Core 3.1 and suddenly stopped working and showing StackOverflow exception in below code at ......
Read more >
Running Azure Functions Locally with the CLI and VS Code
When running locally, a function project (the equivalent of a Function App in Azure) is just a directory with the files host.json and ......
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