Background process exited with code 1

Hey,

We have a React client application that we’re running as a background process during our tests.

The app was bootstrapped with create-react-app.

After running the app as a background process, we then run our unit/integration tests (with Jest) and our E2E tests (with Cypress). The Cypress tests require the app to be running in the background.

Occasionally, the step to run the app fails with this message:

The build failed because the process exited too early. This probably means the system ran out of memory or someone called kill -9 on the process.
error Command failed with exit code 1.
Exited with code 1

This subsequently causes the Cypress tests to fails.

Is there anything we can do to prevent this/debug why the process failed?

Our circle.yml is:

version: 2
jobs:
  build:
    docker:
      # specify the version you desire here
      - image: cypress/base:6
      
      # Specify service dependencies here if necessary
      # CircleCI maintains a library of pre-built images
      # documented at https://circleci.com/docs/2.0/circleci-images/
      # - image: circleci/mongo:3.4.4

    working_directory: ~/repo

    steps:
      - checkout

      # Download and cache dependencies
      - restore_cache:
          keys:
          - v1-dependencies-{{ checksum "package.json" }}
          # fallback to using the latest cache if no exact match is found
          - v1-dependencies-

      - run: yarn install

      - save_cache:
          paths:
            - node_modules
          key: v1-dependencies-{{ checksum "package.json" }}

      - run:
          name: Background the app
          command: yarn start --silent
          background: true

      - run: yarn test

      - run: 
          name: Run E2E tests
          command: $(npm bin)/cypress run --record
          when: on_success

Thanks for any help!

I don’t use Yarn, but I imagine the --silent is not helping you here. Can you remove that switch temporarily? Does Yarn produce logs for the start action?

Also, consider using the SSH option in the Circle UI, and try running commands from the console. I often find that working in a console environment will reveal more information about what is going on.

Thanks for the suggestions!

We were able to fix this by rearranging our config.yml, so that the unit tests weren’t running at the same time as the app was starting. Now we don’t see any more issues with the build running out of memory :tada:

      - run: yarn test

      - run:
          name: Background the app
          command: yarn start
          background: true

      - run:
          name: Run E2E tests
          command: $(npm bin)/cypress run --record
          when: on_success
1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.