【问题标题】:"Workerpool Worker terminated Unexpectedly" for Mocha tests in CircleCI“Workerpool Worker 意外终止”用于 CircleCI 中的 Mocha 测试
【发布时间】:2022-10-21 04:04:31
【问题描述】:

我有使用 Yarn 和 Mocha 运行的 TypeScript 测试,它们在本地运行良好。然而,当我通过 CircleCI 部署时,我得到了这个:

1) Uncaught error outside test suite:
   Uncaught Workerpool Worker terminated Unexpectedly
  exitCode: `null`
  signalCode: `SIGKILL`
  workerpool.script: `/home/circleci/my-project/node_modules/mocha/lib/nodejs/worker.js`
  spawnArgs: `/usr/local/bin/node,--inspect,--inspect=43215,/home/circleci/my-project/node_modules/mocha/lib/nodejs/worker.js`
  spawnfile: `/usr/local/bin/node`
  stdout: `null`
  stderr: `null`

Error: Workerpool Worker terminated Unexpectedly
    exitCode: `null`
    signalCode: `SIGKILL`
    spawnfile: `/usr/local/bin/node`
    stdout: `null`
    stderr: `null`
  
    at ChildProcess.<anonymous> (node_modules/workerpool/src/WorkerHandler.js:294:13)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:282:12)

这是我的 CircleCI 配置。我已经编辑了一些特定于我的项目的字段,并删除了一些在这里没有实际意义的部分,因为它们用于我目前无法运行的作业,因为它们稍后会在此过程中。

version: 2.1

orbs:
  aws-cli: circleci/aws-cli@2.0.6
  assume-role: airswap/assume-role@0.2.0

docker_base: &docker_base
  working_directory: ~/my-funnel  # Edited for privacy
  docker:
    - image: cimg/node:14.18.0
    - image: cimg/openjdk:17.0.1
    - image: amazon/dynamodb-local:1.17.1
      command: -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -inMemory -sharedDb
    - image: roribio16/alpine-sqs:1.2.0

jobs:
  build_and_test:
    <<: *docker_base
    environment:
      APP_ENV: test
      IS_CI: "true"
      # This ID remains here even though I have the Code Climate reporter stuff disabled for now
      CC_TEST_REPORTER_ID: mytestreporterid  # Hex value, redacted for privacy
    steps:
      - checkout
      - run: |
          sudo curl -L https://github.com/remind101/ssm-env/releases/download/v0.0.4/ssm-env -o /usr/local/bin/ssm-env && \
                cd /usr/local/bin && \
                echo 4a5140b04f8b3f84d16a93540daa7bbd ssm-env | md5sum -c && \
                sudo chmod +x ssm-env
      - restore_cache:
          name: Restore Yarn Package Cache
          keys:
            - yarn-packages-{{ checksum "yarn.lock" }}
      - run:
          name: Install Dependencies
          command: yarn install --frozen-lockfile
      - save_cache:
          name: Save Yarn Package Cache
          key: yarn-packages-{{ checksum "yarn.lock" }}
          paths:
            - ~/.cache/yarn
      - run: yarn run lint
      - run: yarn run test # This is where it gives me the Workerpool error
      - run: yarn run package
      - run:
          name: Run Fossa Checks
          command: ./run_fossa.sh

  # A deploy job is defined here, of course, but I'm not getting to the point where I can use it.

workflows:
  no_flow:
    jobs:
      - build_and_test:
          context:
            - fossa
      # There's more here that runs the deploy job; see above comment

我已经xdescribed 完成了所有测试,这仍然会发生。想法赞赏。


更新:我的run.ts 文件中有这一行:

const tests = child_process.spawn(
    "APP_ENV=test NODE_ENV=test ssm-env --with-decryption node_modules/mocha/bin/mocha --inspect -r ts-node/register -r tsconfig-paths/register --recursive 'test/**/*.spec.ts' --parallel",
    { stdio: "inherit", cwd: "./", shell: true }
);

我删除了--parallel,现在一切都很好。仍然对核心问题感到困惑,但至少这是一种解决方法。

【问题讨论】:

  • 你能分享你的circleci配置吗?
  • @JuanFontes 抱歉耽搁了;问题消失了一段时间,但现在它又回来了。为论坛适当编辑的配置现在在那里。
  • 我还看到删除 -p fix things - stackoverflow.com/a/73159525/361714

标签: typescript mocha.js yarnpkg circleci worker-pool


【解决方案1】:

我曾经也有过一样的问题。

实际问题是内存不足。

我分配了更多的内存。我的问题解决了。

【讨论】:

    【解决方案2】:

    每当我并行运行测试并且在实际测试执行之外的测试文件中存在错误时,就会发生此错误(因此不会被 Mocha 捕获)。 “Workerpool Worker 意外终止”错误只是掩盖了实际的潜在错误。

    通过关闭并行运行(配置中的parallel: false 或从 CLI 中删除 -p 标志),我现在可以看到实际的错误被抛出。修复错误后,我可以重新打开并行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多