Bitbucket build failed sonarsource/sonarcloud-scan:1.0.1: Container 'docker' exceeded memory limit

This is a react app.
integrated sonarcloud.
but having issue while building.
We have new problem:
Container ‘docker’ exceeded memory limit.

1 Like

Hi @Manish_K,

There is too little information so that we can help.
Please provide:

  • the error that you see in your pipeline as we cannot see it in your screenshot
  • the content of your bitbucket-pipelines.yml

Cheers

I have updated my question.

Hi,

By default Bitbucket Pipelines jobs have a 4Gb of memory available. The error you get suggests that this was not enough to run your pipeline (either the build or the analysis).

Can you please share the full logs of the step, ideally with debug logs enabled (see here how to enable debug logs), so that we can see if a particular rule uses an unexpected amount of memory.

In the mean time, to fix your setup you can increase the memory limit of your pipeline to 8Gb (see the documentation).

Benoit

Thanks for the reply dear,
I have increase the size but sometime it works but all time not.
I can’t attach log file because it is too big ~12MB
please have a look on pipeline yaml

image: feeni/node-chrome:latest

clone:

  depth: full              # SonarCloud scanner needs the full history to assign issues properly

definitions:

  caches:

    sonar: ~/.sonar/cache  # Caching SonarCloud artifacts will speed up your build

  services:

    docker:

      memory: 2048

  steps:

    - step: &build-test-sonarcloud

        name: Build, test

        caches:

          - node

          - sonar

        script:

          - cd ./src

          - npm install --quiet

          - npm run test -- --code-coverage --no-watch --no-progress --browsers=ChromeHeadlessNoSandbox

    - step: &sonarcloud-scan

        name: analyze on SonarCloud

        size: 2x

        script:

          - pipe: sonarsource/sonarcloud-scan:1.0.1

            variables:

              DEBUG: 'true'

pipelines:

  default:

    - step: *build-test-sonarcloud

    - step: *sonarcloud-scan

  pull-requests:

    '**':

      - step: *build-test-sonarcloud

      - step: *sonarcloud-scan

Unfortunately we cannot help you with only the pipeline.yaml.

Can you upload the log file somewhere and share a link here please?

Here it is
https://1drv.ms/t/s!Aq110i3jtoX-gbsW176uxzwH46rxwg?e=kKIElA
Please view/download

Thank you.
We’ll have a look and come back to you!

Hi @Manish_K

It seems that analysis dies after Sensor SonarJS is started. Does it always die on this step?

Anyway I would advice you to exclude third party files from analysis (I see that there is jquery file analyzed), as there is no sense in evaluating the quality of the code you didn’t write, while it’s taking the resources. You can use sonar.exclusions property for that.

It died sometime, 10% success rate.

I found solution. added files in exclusions.
Thanks Everyone on this thread. :slight_smile:

2 Likes

We’re getting the same error, about 50% of the time. Our project is relatively small (60k lines of code). We’ve tried every solution mentioned in this thread:

  • Source file exclusions
  • Setting “size: 2x” in pipeline definition

It seems to fail at random times during the process as well. Sometimes the sonarcloud-scan pipeline runs for 5 minutes before failing with the aforementioned memory error, sometimes it does so after just a minute.

The actual error in the logs is:
level=error msg=“error waiting for container: unexpected EOF”

Any help would be greatly appreciated, since this really throws a wrench in the works and hobbles our whole CI/CD process with the only solution so far being disabling sonarcloud completely.