ChromeHeadless error stoping npm run test (Angular 7+)

Hi there,

Since yesterday I have been getting an error while testing an angular app. It stops when it tries to kill the browser. I’m attaching the screen for the error.

So far I have tried:

  1. Adding specific configuration to Karma:


    browsers: [‘Chrome’, ‘ChromeHeadless’, ‘ChromeHeadlessCI’],
    browserDisconnectTimeout: 10000,
    browserDisconnectTolerance: 3,
    browserNoActivityTimeout: 60000,
    customLaunchers: {
    ChromeHeadlessCI: {
    base: ‘ChromeHeadless’,
    flags: [’–no-sandbox’, ‘–disable-setuid-sandbox’, ‘–disable-gpu’]
    }
    },

  2. Running ‘npm run test cg-components – --no-watch --no-progress --browsers=ChromeHeadlessCI’ at my console. It doesn’t open the browser and all Unit Tests are executed.

My configuration can be a little uncommon since I’m running Unit Tests for an Angular Project that has a library and other apps (each one has its own Unit Tests).

This is my config.yml file:

version: 2

job_defaults: &job_defaults
  docker:
  - image: circleci/node:latest
    environment:
      CHROME_BIN: /usr/bin/google-chrome
  working_directory: ~/cg-front-end

cache_key: &cache_key cg-front-end-deps-cache-{{ .Branch }}-{{ checksum "package-lock.json" }}
dist_key: &dist_key cg-front-end-dist-{{ .Revision }}

jobs:

  npm-install:
    <<: *job_defaults
    steps:
      - checkout
      - restore_cache:
          key: *cache_key
      - run:
          name: npm-install
          command: npm ci
      - save_cache:
          key: *cache_key
          paths:
            - node_modules

  test-lib:
    <<: *job_defaults
    steps:
      - checkout
      - restore_cache:
          key: *cache_key
      - run:
          name: test-lib
          command: npm run test cg-components -- --no-watch --no-progress --browsers=ChromeHeadlessCI

  build-lib:
    <<: *job_defaults
    steps:
      - checkout
      - restore_cache:
          key: *cache_key
      - run:
          name: build-lib
          command: npm run build cg-components --prod
      - save_cache:
          key: *dist_key
          paths:
              - dist

  test-app:
    <<: *job_defaults
    steps:
      - checkout
      - restore_cache:
          key: *cache_key
      - restore_cache:
          key: *dist_key
      - run:
          name: test-app
          command: npm run test fmvmd-client-front-end -- --no-watch --no-progress --browsers=ChromeHeadlessCI

workflows:
  version: 2
  build-test-release:
    jobs:
      - npm-install
      - test-lib:
          requires:
            - npm-install
      - build-lib:
          requires:
            - test-lib
      - test-app:
          requires:
            - build-lib
          filters:
            branches:
              only: master

Could you save the debug logs as an artifact and share the here?

This is what I got from latest try:

{
  "compare" : null,
  "previous_successful_build" : {
    "build_num" : 124,
    "status" : "success",
    "build_time_millis" : 23583
  },
  "build_parameters" : {
    "CIRCLE_JOB" : "test-lib"
  },
  "oss" : false,
  "all_commit_details_truncated" : false,
  "committer_date" : "2019-04-15T18:20:04-04:00",
  "steps" : [ {
    "name" : "Spin up Environment",
    "actions" : [ {
      "truncated" : false,
      "index" : 0,
      "parallel" : true,
      "failed" : null,
      "infrastructure_fail" : null,
      "name" : "Spin up Environment",
      "bash_command" : null,
      "status" : "success",
      "timedout" : null,
      "continue" : null,
      "end_time" : "2019-04-15T22:21:09.706Z",
      "type" : "test",
      "allocation_id" : "5cb503c40d859800084c82b4-0-build/148AB214",
      "output_url" : "https://circle-production-action-output.s3.amazonaws.com/a8519d10007089060d305bc5-11f11506-73e9-4fbb-b162-0b6cefa2c8a1-0-0?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20190416T133747Z&X-Amz-SignedHeaders=host&X-Amz-Expires=431999&X-Amz-Credential=AKIAIJNI6FA5RIAFFQ7Q%2F20190416%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=49464b7cfcd2ab16427e640a64bcf80af01aef852139d92069b5ebf808d1aa43",
      "start_time" : "2019-04-15T22:21:04.111Z",
      "background" : false,
      "exit_code" : null,
      "insignificant" : false,
      "canceled" : null,
      "step" : 0,
      "run_time_millis" : 5595,
      "has_output" : true
    } ]
  }, {
    "name" : "Checkout code",
    "actions" : [ {
      "truncated" : false,
      "index" : 0,
      "parallel" : true,
      "failed" : null,
      "infrastructure_fail" : null,
      "name" : "Checkout code",
      "bash_command" : "#!/bin/sh\nset -e\n\n# Workaround old docker images with incorrect $HOME\n# check https://github.com/docker/docker/issues/2968 for details\nif [ \"${HOME}\" = \"/\" ]\nthen\n  export HOME=$(getent passwd $(id -un) | cut -d: -f6)\nfi\n\nmkdir -p ~/.ssh\n\necho 'github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==\nbitbucket.org ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAubiN81eDcafrgMeLzaFPsw2kNvEcqTKl/VqLat/MaB33pZy0y3rJZtnqwR2qOOvbwKZYKiEO1O6VqNEBxKvJJelCq0dTXWT5pbO2gDXC6h6QDXCaHo6pOHGPUy+YBaGQRGuSusMEASYiWunYN0vCAI8QaXnWMXNMdFP3jHAJH0eDsoiGnLPBlBp4TNm6rYI74nMzgz3B9IikW4WVK+dc8KZJZWYjAuORU3jc1c/NPskD2ASinf8v3xnfXeukU0sJ5N6m5E8VLjObPEO+mN2t/FZTMZLiFqPWc/ALSqnMnnhwrNi2rbfg/rd/IpL8Le3pSBne8+seeFVBoGqzHM9yXw==\n' >> ~/.ssh/known_hosts\n\n(umask 077; touch ~/.ssh/id_rsa)\nchmod 0600 ~/.ssh/id_rsa\n(cat <<EOF > ~/.ssh/id_rsa\n$CHECKOUT_KEY\nEOF\n)\n\n# use git+ssh instead of https\ngit config --global url.\"ssh://git@github.com\".insteadOf \"https://github.com\" || true\ngit config --global gc.auto 0 || true\n\nif [ -e /home/circleci/cg-front-end/.git ]\nthen\n  cd /home/circleci/cg-front-end\n  git remote set-url origin \"$CIRCLE_REPOSITORY_URL\" || true\nelse\n  mkdir -p /home/circleci/cg-front-end\n  cd /home/circleci/cg-front-end\n  git clone \"$CIRCLE_REPOSITORY_URL\" .\nfi\n\nif [ -n \"$CIRCLE_TAG\" ]\nthen\n  git fetch --force origin \"refs/tags/${CIRCLE_TAG}\"\nelse\n  git fetch --force origin \"master:remotes/origin/master\"\nfi\n\n\nif [ -n \"$CIRCLE_TAG\" ]\nthen\n  git reset --hard \"$CIRCLE_SHA1\"\n  git checkout -q \"$CIRCLE_TAG\"\nelif [ -n \"$CIRCLE_BRANCH\" ]\nthen\n  git reset --hard \"$CIRCLE_SHA1\"\n  git checkout -q -B \"$CIRCLE_BRANCH\"\nfi\n\ngit reset --hard \"$CIRCLE_SHA1\"",
      "status" : "success",
      "timedout" : null,
      "continue" : null,
      "end_time" : "2019-04-15T22:21:10.575Z",
      "type" : "test",
      "allocation_id" : "5cb503c40d859800084c82b4-0-build/148AB214",
      "output_url" : "https://circle-production-action-output.s3.amazonaws.com/2d519d10007089065d305bc5-11f11506-73e9-4fbb-b162-0b6cefa2c8a1-101-0?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20190416T133747Z&X-Amz-SignedHeaders=host&X-Amz-Expires=431999&X-Amz-Credential=AKIAIJNI6FA5RIAFFQ7Q%2F20190416%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=186c433d8e04187805665c27d9fb0e6a1a71a17b541d56af54ace72238cca9ad",
      "start_time" : "2019-04-15T22:21:09.795Z",
      "background" : false,
      "exit_code" : 0,
      "insignificant" : false,
      "canceled" : null,
      "step" : 101,
      "run_time_millis" : 780,
      "has_output" : true
    } ]
  }, {
    "name" : "Restoring Cache",
    "actions" : [ {
      "truncated" : false,
      "index" : 0,
      "parallel" : true,
      "failed" : null,
      "infrastructure_fail" : null,
      "name" : "Restoring Cache",
      "bash_command" : null,
      "status" : "success",
      "timedout" : null,
      "continue" : null,
      "end_time" : "2019-04-15T22:21:17.371Z",
      "type" : "test",
      "allocation_id" : "5cb503c40d859800084c82b4-0-build/148AB214",
      "output_url" : "https://circle-production-action-output.s3.amazonaws.com/6d519d10007089066d305bc5-11f11506-73e9-4fbb-b162-0b6cefa2c8a1-102-0?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20190416T133747Z&X-Amz-SignedHeaders=host&X-Amz-Expires=431999&X-Amz-Credential=AKIAIJNI6FA5RIAFFQ7Q%2F20190416%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=d4d0a0bb1872639c797a719e99cb95a354e1e6e4c542cd50fc4101b06a50e167",
      "start_time" : "2019-04-15T22:21:10.582Z",
      "background" : false,
      "exit_code" : null,
      "insignificant" : false,
      "canceled" : null,
      "step" : 102,
      "run_time_millis" : 6789,
      "has_output" : true
    } ]
  }, {
    "name" : "test-lib",
    "actions" : [ {
      "truncated" : false,
      "index" : 0,
      "parallel" : true,
      "failed" : true,
      "infrastructure_fail" : null,
      "name" : "test-lib",
      "bash_command" : "#!/bin/bash -eo pipefail\nnpm run test cg-components -- --no-watch --no-progress --browsers=ChromeHeadlessCI",
      "status" : "failed",
      "timedout" : null,
      "continue" : null,
      "end_time" : "2019-04-15T22:22:32.032Z",
      "type" : "test",
      "allocation_id" : "5cb503c40d859800084c82b4-0-build/148AB214",
      "output_url" : "https://circle-production-action-output.s3.amazonaws.com/41619d1000708906dd305bc5-11f11506-73e9-4fbb-b162-0b6cefa2c8a1-103-0?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20190416T133747Z&X-Amz-SignedHeaders=host&X-Amz-Expires=431999&X-Amz-Credential=AKIAIJNI6FA5RIAFFQ7Q%2F20190416%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=aea3f53c4469c940e8006d5c09046a0979120321f5c094469d6842ed5a38eb10",
      "start_time" : "2019-04-15T22:21:17.377Z",
      "background" : false,
      "exit_code" : 1,
      "insignificant" : false,
      "canceled" : null,
      "step" : 103,
      "run_time_millis" : 74655,
      "has_output" : true
    } ]
  } ],
  "body" : "",
  "usage_queued_at" : "2019-04-15T22:20:59.781Z",
  "context_ids" : [ ],
  "fail_reason" : null,
  "retry_of" : null,
  "reponame" : "cg-front-end",
  "ssh_users" : [ ],
  "build_url" : "https://circleci.com/gh/diegolsarmiento/cg-front-end/125",
  "parallel" : 1,
  "failed" : true,
  "branch" : "master",
  "username" : "diegolsarmiento",
  "author_date" : "2019-04-15T18:20:04-04:00",
  "why" : "github",
  "user" : {
    "is_user" : true,
    "login" : "diegolsarmiento",
    "avatar_url" : "https://avatars1.githubusercontent.com/u/44205748?v=4",
    "name" : "Diego Sarmiento",
    "vcs_type" : "github",
    "id" : 44205748
  },
  "vcs_revision" : "236d3f55a44c35c847c780a79bca10eaa772b9c6",
  "workflows" : {
    "job_name" : "test-lib",
    "job_id" : "e2c7de48-6c62-4718-8203-ba8116e149f7",
    "workflow_id" : "4011d9e7-d46f-43d2-a4d4-3bf7b33216da",
    "workspace_id" : "4011d9e7-d46f-43d2-a4d4-3bf7b33216da",
    "upstream_job_ids" : [ "03495261-8a58-44f6-9a6e-40d6bddf5a14" ],
    "upstream_concurrency_map" : { },
    "workflow_name" : "build-test-release"
  },
  "owners" : [ "diegolsarmiento" ],
  "vcs_tag" : null,
  "pull_requests" : [ ],
  "build_num" : 125,
  "infrastructure_fail" : false,
  "committer_email" : "diego@cg.com",
  "has_artifacts" : true,
  "previous" : {
    "build_num" : 124,
    "status" : "success",
    "build_time_millis" : 23583
  },
  "status" : "failed",
  "committer_name" : "Diego Sarmiento",
  "retries" : null,
  "subject" : "fixed basic unit tests for fmvmd-website",
  "vcs_type" : "github",
  "timedout" : false,
  "dont_build" : null,
  "lifecycle" : "finished",
  "no_dependency_cache" : false,
  "stop_time" : "2019-04-15T22:22:32.056Z",
  "ssh_disabled" : true,
  "build_time_millis" : 88851,
  "picard" : {
    "build_agent" : {
      "image" : "circleci/picard:1.0.10495-4fff0daa",
      "properties" : {
        "build_agent" : "1.0.10495-4fff0daa",
        "executor" : "docker"
      }
    },
    "resource_class" : {
      "cpu" : 2.0,
      "ram" : 4096,
      "class" : "medium"
    },
    "executor" : "docker"
  },
  "circle_yml" : {
    "string" : "version: 2\njob_defaults:\n  docker:\n  - image: circleci/node:latest\n    environment:\n      CHROME_BIN: /usr/bin/google-chrome\n  working_directory: ~/cg-front-end\ncache_key: cg-front-end-deps-cache-{{ .Branch }}-{{ checksum \"package-lock.json\" }}\ndist_key: cg-front-end-dist-{{ .Revision }}\njobs:\n  npm-install:\n    docker:\n    - image: circleci/node:latest\n      environment:\n        CHROME_BIN: /usr/bin/google-chrome\n    working_directory: ~/cg-front-end\n    steps:\n    - checkout\n    - restore_cache:\n        key: cg-front-end-deps-cache-{{ .Branch }}-{{ checksum \"package-lock.json\"\n          }}\n    - run:\n        name: npm-install\n        command: npm ci\n    - save_cache:\n        key: cg-front-end-deps-cache-{{ .Branch }}-{{ checksum \"package-lock.json\"\n          }}\n        paths:\n        - node_modules\n  test-lib:\n    docker:\n    - image: circleci/node:latest\n      environment:\n        CHROME_BIN: /usr/bin/google-chrome\n    working_directory: ~/cg-front-end\n    steps:\n    - checkout\n    - restore_cache:\n        key: cg-front-end-deps-cache-{{ .Branch }}-{{ checksum \"package-lock.json\"\n          }}\n    - run:\n        name: test-lib\n        command: npm run test cg-components -- --no-watch --no-progress --browsers=ChromeHeadlessCI\n  build-lib:\n    docker:\n    - image: circleci/node:latest\n      environment:\n        CHROME_BIN: /usr/bin/google-chrome\n    working_directory: ~/cg-front-end\n    steps:\n    - checkout\n    - restore_cache:\n        key: cg-front-end-deps-cache-{{ .Branch }}-{{ checksum \"package-lock.json\"\n          }}\n    - run:\n        name: build-lib\n        command: npm run build cg-components --prod\n    - save_cache:\n        key: cg-front-end-dist-{{ .Revision }}\n        paths:\n        - dist\n  test-app:\n    docker:\n    - image: circleci/node:latest\n      environment:\n        CHROME_BIN: /usr/bin/google-chrome\n    working_directory: ~/cg-front-end\n    steps:\n    - checkout\n    - restore_cache:\n        key: cg-front-end-deps-cache-{{ .Branch }}-{{ checksum \"package-lock.json\"\n          }}\n    - restore_cache:\n        key: cg-front-end-dist-{{ .Revision }}\n    - run:\n        name: test-app\n        command: npm run test fmvmd-client-front-end -- --no-watch --no-progress --browsers=ChromeHeadlessCI\nworkflows:\n  version: 2\n  build-test-release:\n    jobs:\n    - npm-install\n    - test-lib:\n        requires:\n        - npm-install\n    - build-lib:\n        requires:\n        - test-lib\n    - test-app:\n        requires:\n        - build-lib\n        filters:\n          branches:\n            only: master\n"
  },
  "messages" : [ ],
  "is_first_green_build" : false,
  "job_name" : null,
  "start_time" : "2019-04-15T22:21:03.205Z",
  "canceler" : null,
  "all_commit_details" : [ {
    "committer_date" : "2019-04-15T18:20:04-04:00",
    "body" : "",
    "branch" : "master",
    "author_date" : "2019-04-15T18:20:04-04:00",
    "committer_email" : "diego@cg.com",
    "commit" : "236d3f55a44c35c847c780a79bca10eaa772b9c6",
    "committer_login" : "diegolsarmiento",
    "committer_name" : "Diego Sarmiento",
    "subject" : "fixed basic unit tests for fmvmd-website",
    "commit_url" : "//github-account/cg-front-end/commit/236d3f55a44c35c847c780a79bca10eaa772b9c6",
    "author_login" : "diegolsarmiento",
    "author_name" : "Diego Sarmiento",
    "author_email" : "diego@cg.com"
  } ],
  "platform" : "2.0",
  "outcome" : "failed",
  "vcs_url" : "//github-account/cg-front-end",
  "author_name" : "Diego Sarmiento",
  "node" : null,
  "queued_at" : "2019-04-15T22:21:00.423Z",
  "canceled" : false,
  "author_email" : "diego@cg.com"
}

I figured it out: Changed the cache_key and dist_key config to:

cache_key: &cache_key cg-front-end-{{ .Branch }}-{{ checksum “package-lock.json” }}
dist_key: &dist_key cg-front-end-dist-{{ .Revision }}

It runs all tests, including the library and the app.

2 Likes

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