Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CfnDistribution_ throws 'Collection was modified' #690

Closed
1 of 5 tasks
McDoit opened this issue Jul 11, 2019 · 0 comments · Fixed by #691
Closed
1 of 5 tasks

CfnDistribution_ throws 'Collection was modified' #690

McDoit opened this issue Jul 11, 2019 · 0 comments · Fixed by #691
Labels
bug This issue is a bug. language/dotnet Related to .NET bindings (C#, F#, ...)

Comments

@McDoit
Copy link

McDoit commented Jul 11, 2019

Note: for support questions, please first reference our documentation, then use Stackoverflow. This repository's issues are intended for feature requests and bug reports.

  • I'm submitting a ...

    • 🪲 bug report
    • 🚀 feature request
    • 📚 construct library gap
    • ☎️ security issue or vulnerability => Please see policy
    • ❓ support request => Please see note at the top of this template.
  • What is the current behavior?
    If the current behavior is a 🪲bug🪲: Please provide the steps to reproduce

Init a new App

Create a new stack with a single CfnDistribution_

                new CfnDistribution_(this, "MyDistribution", new CfnDistributionProps
                {
                    DistributionConfig = new DistributionConfigProperty
                    {
                        Enabled = false
                    }
                });

Trying to synth, deploy etc throws the following error:
Unhandled Exception: Amazon.JSII.Runtime.JsiiException: Amazon.JSII.Runtime.JsiiException: Resolution error: System.InvalidOperationException: Collection was modified; enumeration operation may not execute.

  • What is the expected behavior (or behavior of feature suggested)?

To create a CloudFront distribution

  • What is the motivation / use case for changing the behavior or adding this feature?

  • Please tell us about your environment:

    • CDK CLI Version: 0.39
    • Module Version: 0.39.0-devpreview
    • OS: [Windows 10]
    • Language: [C# ]
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. associated pull-request, stackoverflow, gitter, etc)

Unhandled Exception: Amazon.JSII.Runtime.JsiiException: Amazon.JSII.Runtime.JsiiException: Resolution error: System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
   at System.Collections.Generic.Dictionary`2.KeyCollection.Enumerator.MoveNext()
   at Amazon.JSII.Runtime.CallbackExtensions.FromKernel(Object obj, IReferenceMap referenceMap)
   at System.Linq.Enumerable.SelectArrayIterator`2.ToArray()
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at Amazon.JSII.Runtime.CallbackExtensions.InvokeMethod(InvokeRequest request, IReferenceMap referenceMap)
   at Amazon.JSII.Runtime.CallbackExtensions.InvokeCallback(Callback callback, IReferenceMap referenceMap, IFrameworkToJsiiConverter converter, String& error).
Object creation stack:
  at new Intrinsic (C:\Users\user~1\AppData\Local\Temp\jsii-kernel-vXyBEe\node_modules\@aws-cdk\core\lib\private\intrinsic.js:20:44)
  at new PostResolveToken (C:\Users\user~1\AppData\Local\Temp\jsii-kernel-vXyBEe\node_modules\@aws-cdk\core\lib\util.js:72:9)
  at CfnDistribution._toCloudFormation (C:\Users\user~1\AppData\Local\Temp\jsii-kernel-vXyBEe\node_modules\@aws-cdk\core\lib\cfn-resource.js:167:39)
  at node.addReference.resolve_1.findTokens (C:\Users\user~1\AppData\Local\Temp\jsii-kernel-vXyBEe\node_modules\@aws-cdk\core\lib\cfn-element.js:84:77)
  at Object.findTokens (C:\Users\user~1\AppData\Local\Temp\jsii-kernel-vXyBEe\node_modules\@aws-cdk\core\lib\private\resolve.js:125:13)
  at CfnDistribution.prepare (C:\Users\user~1\AppData\Local\Temp\jsii-kernel-vXyBEe\node_modules\@aws-cdk\core\lib\cfn-element.js:84:49)
  at _wrapSandboxCode (C:\Users\username\AppData\Local\Temp\ppvhhyvn.zhu\jsii-runtime.js:6493:51)
  at Kernel._wrapSandboxCode (C:\Users\username\AppData\Local\Temp\ppvhhyvn.zhu\jsii-runtime.js:7126:20)
  at ret._ensureSync (C:\Users\username\AppData\Local\Temp\ppvhhyvn.zhu\jsii-runtime.js:6493:25)
  at Kernel._ensureSync (C:\Users\username\AppData\Local\Temp\ppvhhyvn.zhu\jsii-runtime.js:7097:20)
  at Kernel.invoke (C:\Users\username\AppData\Local\Temp\ppvhhyvn.zhu\jsii-runtime.js:6492:26)
  at KernelHost.processRequest (C:\Users\username\AppData\Local\Temp\ppvhhyvn.zhu\jsii-runtime.js:6186:28)
  at completeCallback (C:\Users\username\AppData\Local\Temp\ppvhhyvn.zhu\jsii-runtime.js:6159:25)
  at KernelHost.callbackHandler (C:\Users\username\AppData\Local\Temp\ppvhhyvn.zhu\jsii-runtime.js:6140:16)
  at KernelHost.kernel.jsii_kernel_1.Kernel.cb [as callbackHandler] (C:\Users\username\AppData\Local\Temp\ppvhhyvn.zhu\jsii-runtime.js:6124:59)
  at CfnDistribution.value (C:\Users\username\AppData\Local\Temp\ppvhhyvn.zhu\jsii-runtime.js:6843:41)
  at Function.prepare (C:\Users\user~1\AppData\Local\Temp\jsii-kernel-vXyBEe\node_modules\@aws-cdk\core\lib\construct.js:89:27)
  at Function.synth (C:\Users\user~1\AppData\Local\Temp\jsii-kernel-vXyBEe\node_modules\@aws-cdk\core\lib\construct.js:52:14)
  at App.synth (C:\Users\user~1\AppData\Local\Temp\jsii-kernel-vXyBEe\node_modules\@aws-cdk\core\lib\app.js:67:52)
  at _wrapSandboxCode (C:\Users\username\AppData\Local\Temp\ppvhhyvn.zhu\jsii-runtime.js:6493:51)
  at Kernel._wrapSandboxCode (C:\Users\username\AppData\Local\Temp\ppvhhyvn.zhu\jsii-runtime.js:7126:20)
  at ret._ensureSync (C:\Users\username\AppData\Local\Temp\ppvhhyvn.zhu\jsii-runtime.js:6493:25)
  at Kernel._ensureSync (C:\Users\username\AppData\Local\Temp\ppvhhyvn.zhu\jsii-runtime.js:7097:20)
  at Kernel.invoke (C:\Users\username\AppData\Local\Temp\ppvhhyvn.zhu\jsii-runtime.js:6492:26)
  at KernelHost.processRequest (C:\Users\username\AppData\Local\Temp\ppvhhyvn.zhu\jsii-runtime.js:6186:28)
  at KernelHost.run (C:\Users\username\AppData\Local\Temp\ppvhhyvn.zhu\jsii-runtime.js:6132:14)
  at processRequest (C:\Users\username\AppData\Local\Temp\ppvhhyvn.zhu\jsii-runtime.js:6132:45)
  at KernelHost.processRequest (C:\Users\username\AppData\Local\Temp\ppvhhyvn.zhu\jsii-runtime.js:6228:16)
  at KernelHost.run (C:\Users\username\AppData\Local\Temp\ppvhhyvn.zhu\jsii-runtime.js:6132:14)
  at processRequest (C:\Users\username\AppData\Local\Temp\ppvhhyvn.zhu\jsii-runtime.js:6132:45)
  at KernelHost.processRequest (C:\Users\username\AppData\Local\Temp\ppvhhyvn.zhu\jsii-runtime.js:6228:16)
  at KernelHost.run (C:\Users\username\AppData\Local\Temp\ppvhhyvn.zhu\jsii-runtime.js:6132:14)
  at processRequest (C:\Users\username\AppData\Local\Temp\ppvhhyvn.zhu\jsii-runtime.js:6132:45)
  at promise.then.val (C:\Users\username\AppData\Local\Temp\ppvhhyvn.zhu\jsii-runtime.js:6213:21)
   at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
   at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
   at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
   at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
   at Amazon.JSII.Runtime.Deputy.DeputyBase.<InvokeMethodCore>g__GetResult|18_0[T](<>c__DisplayClass18_0`1& )
   at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeMethodCore[T](JsiiMethodAttribute methodAttribute, Object[] arguments, Func`3 beginFunc, Func`3 invokeFunc)
   at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeInstanceMethod[T](Object[] arguments, String methodName)
   at Amazon.CDK.CfnElement.Prepare()
   at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
   at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
   at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
   at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
   at Amazon.JSII.Runtime.Deputy.DeputyBase.<InvokeMethodCore>g__GetResult|18_0[T](<>c__DisplayClass18_0`1& )
   at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeMethodCore[T](JsiiMethodAttribute methodAttribute, Object[] arguments, Func`3 beginFunc, Func`3 invokeFunc)
   at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeInstanceMethod[T](Object[] arguments, String methodName)
   at HelloCdk.Program.Main(String[] args) in D:\Development\emg-public-cloudfront-test\src\HelloCdk\Program.cs:line 34
Subprocess exited with error 3762504530
@RomainMuller RomainMuller transferred this issue from aws/aws-cdk Aug 8, 2019
@RomainMuller RomainMuller added bug This issue is a bug. language/dotnet Related to .NET bindings (C#, F#, ...) labels Aug 8, 2019
RomainMuller added a commit that referenced this issue Aug 8, 2019
When bringding callback results into dotnet types, we used to modify the
Dictionary item within the loop, which is illegal in C#. Any mutation on
the collection will cause the iterator to abort.

Insead, create a new Dictionary and add the resolved values to that.

Fixes #690
RomainMuller added a commit that referenced this issue Aug 9, 2019
When bringding callback results into dotnet types, we used to modify the
Dictionary item within the loop, which is illegal in C#. Any mutation on
the collection will cause the iterator to abort.

Insead, create a new Dictionary and add the resolved values to that.

Fixes #690
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. language/dotnet Related to .NET bindings (C#, F#, ...)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants