Uploaded image for project: 'Couchbase .NET client library'
  1. Couchbase .NET client library
  2. NCBC-2638

Intermittent InvalidOperationException in Dependency Injection

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 3.0.6
    • 3.0.4
    • library
    • None
    • 1

    Description

      From forums: https://forums.couchbase.com/t/intermittent-invalidoperationexception-in-dependency-injection/27168

      I’m using CouchbaseNetClient v3.0.4 and Couchbase.Extensions.DependencyInjection v3.0.4.811, both from Nuget… I’m seeing some intermittent errors when I call GetBucketAsync. If I retry the operation it will eventually be successful.

      My code is pretty simple: I call AddCouchbase(Configuration.GetSection("Couchbase")) in Startup.ConfigureServices. I inject IBucketProvider and then do var bucket = await _bucketProvider.GetBucketAsync("mybucket");

      Here’s the stack trace:

      System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
      at System.Collections.Generic.Dictionary`2.Enumerator.MoveNext()
      at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
      at Couchbase.Core.DI.CouchbaseServiceProvider..ctor(IEnumerable`1 serviceFactories)
      at Couchbase.ClusterOptions.BuildServiceProvider()
      at Couchbase.Core.ClusterContext..ctor(ICluster cluster, CancellationTokenSource tokenSource, ClusterOptions options)
      at Couchbase.Cluster..ctor(ClusterOptions clusterOptions)
      at Couchbase.Cluster.ConnectAsync(ClusterOptions options)
      at Couchbase.Extensions.DependencyInjection.Internal.ClusterProvider.GetClusterAsync()
      at Couchbase.Extensions.DependencyInjection.Internal.BucketProvider.<GetBucketAsync>b__4_0(String name)

      I’d really appreciate any help you can offer. Thanks, and have a good weekend.

      Attachments

        For Gerrit Dashboard: NCBC-2638
        # Subject Branch Project Status CR V

        Activity

          People

            btburnett3 Brant Burnett
            jmorris Jeff Morris
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty