ember-cli: Error: Cannot start a build if one is already running

After upgrading to ember-cli 3.17.1 this error started popping up frequently.

If you have ember s running and editing files quickly it will show up. Edit one file, save, go to another file, edit and save before the previous incremental build is finished, the “Cannot start a build if one is already running” error pops up and live-reload won’t recover. It needs to be restarted.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 12
  • Comments: 19 (14 by maintainers)

Most upvoted comments

Reverted the changes in https://github.com/broccolijs/broccoli/pull/459 and released as broccoli@3.4.1.

I believe this issue is actually fixed. If you are getting pinned to an older affected broccoli version, you may need to update your lock file…

Sorry about closing this issue and needing to reopen it. This issue was referenced from a PR in a private repo, and merging that PR apparently auto-closed this issue 😬

Ok, I believe the following should be done:

  1. disable the existing behavior in broccoli
  2. release This addresses the concern quickly, allowing us to make appropriate changes in broccoli

Changes in broccoli: Rather then cancelling as is, we need to introduce the concept, using the existing cancellation plumbing, a retryable cancellation.

It will more or less be.

  • builder.cancel(new RetryCancellationException('mid-build watch occurred, attempt retry') or simply builder.retry() and use RetryCancellationException internally
  • builder.build learns about RetryCancellationException, and if a build fails do to a RetryCancellationException it will internally restart itself
  • We could consider an internal limit on retries, to prevent infinite loops here. That threshold needs to be decided.

I’m going to disable this in broccoli + release now, then kick the tires on the above solution

There might be a better way of doing this too, but I was able to downgrade like this as a workaround:

# remove broccoli from package-lock
npm uninstall --save-dev ember-cli

# install pinned version of broccoli at 3.3
npm install --save-dev broccoli@3.3

# install downgraded ember-cli which won't force
# broccoli 3.4 since current install already meets reqs
npm install --save-dev ember-cli@3.16

# get rid of explicit dep on broccoli from package.json
npm uninstall --save-dev broccoli

Note that simply downgrading ember-cli won’t downgrade broccoli, because ^ ranges make npm think that 3.4.0 is a safe upgrade.

I’m sure there’s a fancypants way of doing this more easily with yarn too.

Edit: I suppose after downgrading broccoli, you can install ember-cli@3.17 too, since the transitive dep range didn’t change.