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

Error: Cannot start a build if one is already running #9127

Closed
andreyfel opened this issue Mar 25, 2020 · 19 comments
Closed

Error: Cannot start a build if one is already running #9127

andreyfel opened this issue Mar 25, 2020 · 19 comments

Comments

@andreyfel
Copy link

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.

@nickschot
Copy link
Contributor

Also noticed this on 3.16.4/5.

@wagenet
Copy link
Contributor

wagenet commented Mar 26, 2020

This has started happening to me very frequently on an app running ember-cli 3.17.

@houfeng0923
Copy link
Contributor

i used ember3.17.0 , it happens frequently when code changed

PLATFORM: darwin x64
  FREEMEM: 186888192
  TOTALMEM: 8589934592
  UPTIME: 8965
  LOADAVG: 6.65380859375,3.20849609375,3.458984375
  CPUS:
  - Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz - 2700
  - Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz - 2700
  - Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz - 2700
  - Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz - 2700
  ENDIANNESS: LE
  VERSIONS:
  - ares: 1.15.0
  - brotli: 1.0.7
  - cldr: 35.1
  - http_parser: 2.9.3
  - icu: 64.2
  - llhttp: 2.0.4
  - modules: 72
  - napi: 5
  - nghttp2: 1.40.0
  - node: 12.16.0
  - openssl: 1.1.1d
  - tz: 2019c
  - unicode: 12.1
  - uv: 1.34.0
  - v8: 7.8.279.23-node.31
  - zlib: 1.2.11

ERROR Summary:

  - broccoliBuilderErrorStack: [undefined]
  - code: [undefined]
  - codeFrame: [undefined]
  - errorMessage: Cannot start a build if one is already running
  - errorType: [undefined]
  - location:
    - column: [undefined]
    - file: [undefined]
    - line: [undefined]
  - message: Cannot start a build if one is already running
  - name: Error
  - nodeAnnotation: [undefined]
  - nodeName: [undefined]
  - originalErrorMessage: [undefined]
  - stack: Error: Cannot start a build if one is already running
    at Builder.build (/Users/ember-test/node_modules/broccoli/dist/builder.js:100:19)
    at /Users/ember-test/node_modules/ember-cli/lib/models/builder.js:200:32

=================================================================================

@jordpo
Copy link

jordpo commented Mar 26, 2020

Yeah I'm seeing this a lot now. Happens when you do rapid code changes in a row.

@jordpo
Copy link

jordpo commented Mar 26, 2020

So you don't necessarily have to restart. You can do another change and let the build finish and livereload should recover.

@rwjblue
Copy link
Member

rwjblue commented Mar 26, 2020

This is coming from:

https://github.com/broccolijs/broccoli/blob/30f95811a966233e944a5912f5b2f4be5e157ef1/lib/builder.ts#L128

Which has been around for a while now, but I suspect the actual issue was introduced by broccolijs/broccoli#408.

@gabrielcsapo / @stefanpenner - Either of you have time to poke at this?

@mehulkar
Copy link
Contributor

mehulkar commented Mar 26, 2020

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 [email protected]

# install downgraded ember-cli which won't force
# broccoli 3.4 since current install already meets reqs
npm install --save-dev [email protected]

# 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 [email protected] too, since the transitive dep range didn't change.

@gabrielcsapo
Copy link

Looking into this now

@gabrielcsapo
Copy link

https://github.com/ember-cli/ember-cli/blob/master/lib/models/builder.js#L205, this looks like we need to guard against cancellations because those are expected with this change.

@stefanpenner
Copy link
Contributor

I think we need to:

option 1) Figure out how to hide this in broccoli
option 2) If we cannot, then we must:

  1. disable this is broccoli (as the fix may be ember-cli)
  2. fix this in ember-cli
  3. have ember-cli opt-in to this functionality in broccoli

@stefanpenner
Copy link
Contributor

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

@rwjblue
Copy link
Member

rwjblue commented Mar 30, 2020

Reverted the changes in broccolijs/broccoli#459 and released as [email protected].

@stefanpenner
Copy link
Contributor

WIP: rework, to fix this: broccolijs/broccoli#458

@dgeb dgeb closed this as completed Mar 31, 2020
@dgeb dgeb reopened this Apr 1, 2020
@dgeb
Copy link
Member

dgeb commented Apr 1, 2020

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 😬

@lolmaus
Copy link
Contributor

lolmaus commented Oct 8, 2020

This has been a small nuisance for me, but in one of my projects I have to restart the dev server like five times in a row before I get a successful build, and then it will randomly break on a rebuild. So it's almost blocking.

When it happened in a sequence for the first time, I had an impression that it broke for good. I just couldn't get it to work. But then an Nth attempt succeeded.

Is there a workaround or something?

@lolmaus
Copy link
Contributor

lolmaus commented Oct 8, 2020

Adding this to package.json and running yarn seems to help:

  "resolutions": {
    "broccoli": "3.4.1"
  }

I hope it works not only because I suddenly got lucky. 😅

@rwjblue
Copy link
Member

rwjblue commented Oct 8, 2020

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...

@locks
Copy link
Contributor

locks commented Jan 10, 2022

Closing due to inactivity. If the last comment about this problem being fixed is not accurate, please let us know!

@locks locks closed this as completed Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests