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.

Race Issue when deploying multiple stacks in parallel

See original GitHub issue

I have a loop,

for stack in Stack1 Stack2 Stack3 
do
  cdk deploy $stack &
end

As written, the first one will sometimes die with this error:

SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at new CloudAssembly (/Users/sblackstone/code/lotto/stacks/node_modules/@aws-cdk/cx-api/lib/cloud-assembly.js:25:31)
    at CloudAssemblyBuilder.buildAssembly (/Users/sblackstone/code/lotto/stacks/node_modules/@aws-cdk/cx-api/lib/cloud-assembly.js:193:16)
    at Function.synth (/Users/sblackstone/code/lotto/stacks/node_modules/@aws-cdk/core/lib/construct.js:72:24)
    at App.synth (/Users/sblackstone/code/lotto/stacks/node_modules/@aws-cdk/core/lib/app.js:71:52)
    at process.<anonymous> (/Users/sblackstone/code/lotto/stacks/node_modules/@aws-cdk/core/lib/app.js:45:51)
    at Object.onceWrapper (events.js:291:20)
    at process.emit (events.js:203:13)
Subprocess exited with error 1

Adding a sleep 3 in that loop fixes the problem…

Thanks

Environment

  • CLI Version 1.20.0 (build 021c521) :
  • OS OSX :
  • Language Javascript :

This is 🐛 Bug Report

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
richardhboydcommented, Feb 2, 2020

maybe I am missing something, but why not use cdk deploy Stack* and let CDK handle ordering/deploying them?

0reactions
shivlakscommented, May 16, 2020

resolving this as cdk deploy '*' will give you what you need as @richardhboyd mentioned. please reopen if you’re still running into issues here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CDK Shorts #2 – Parallel Deployments | Rehan van der Merwe
CDK stacks can be deployed in parallel by generating a cloud assembly output and then specifying the order explicitly.
Read more >
Prevent parallel execution of the same build definition
The issue at hand is to ensure that a build pipeline runs in sequence and not in parallel if triggered by e.g. multiple...
Read more >
Configuring queued, superseded, and parallel runs
Queues form at the entry points to actions and action groups, so you can have multiple queues within the same workflow (see Figure...
Read more >
Data Race Patterns in Go | Uber Blog
Higher concurrency also means potential for more concurrency bugs. A data race is a concurrency bug that occurs when two or more goroutines ......
Read more >
Advanced Workflows with Parallel steps · Codefresh | Docs
Codefresh allows you insert a parallel phase inside a sequential pipeline with ... If there are race conditions between your parallel steps, (e.g....
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