wallabyjs / public

Repository for Wallaby.js questions and issues
http://wallabyjs.com
760 stars 45 forks source link

Runtime error: Farm is ended, no more calls can be done to it​​ #3181

Closed apaniel closed 1 year ago

apaniel commented 1 year ago

Issue description or question

Wallaby tests were working fine, now they don't run, this error is shown: Runtime error: Farm is ended, no more calls can be done to it​​.

To add more information, this is a pnpm monorepo and jest is installed in the root of the monorepo, instead of each workspace. It has been working fine for a while with this setup, until it didn't.

Wallaby diagnostics report

{
  editorVersion: '1.75.1',
  pluginVersion: '1.0.350',
  editorType: 'VSCode',
  osVersion: 'darwin 22.3.0',
  nodeVersion: 'v16.16.0',
  coreVersion: '1.0.1390',
  checksum: 'YzZlMWI5ZWRlODlhODc4OWVhMmEyZDc0YjQyYWYxNDgsMTcwMDUyNDgwMDAwMCww',
  config: {
    diagnostics: {
      jest: {
        config: {
          configs: [
            {
              automock: false,
              cache: true,
              cacheDirectory: '/private/var/folders/ps/4n0jh1l17nd4s9bxcqvvs_xh0000gq/T/jest_dz',
              clearMocks: false,
              coveragePathIgnorePatterns: [ '/node_modules/' ],
              cwd: '<homeDir>/Desktop/Repos/monorepo/app/services/api',
              dependencyExtractor: undefined,
              detectLeaks: false,
              detectOpenHandles: false,
              displayName: undefined,
              errorOnDeprecated: false,
              extensionsToTreatAsEsm: [],
              fakeTimers: { enableGlobally: false },
              filter: undefined,
              forceCoverageMatch: [],
              globalSetup: undefined,
              globalTeardown: undefined,
              globals: {},
              haste: { computeSha1: false, enableSymlinks: false, forceNodeFilesystemAPI: true, throwOnModuleCollision: false },
              id: 'e93902fec2478e0f623b8daaae1c635f',
              injectGlobals: true,
              moduleDirectories: [ 'node_modules' ],
              moduleFileExtensions: [
                'js',   'mjs',
                'cjs',  'jsx',
                'ts',   'tsx',
                'json', 'node'
              ],
              moduleNameMapper: [ [ '^~/(.*)$', '<homeDir>/Desktop/Repos/monorepo/app/services/api/src/$1' ] ],
              modulePathIgnorePatterns: [],
              modulePaths: undefined,
              prettierPath: 'prettier',
              resetMocks: true,
              resetModules: false,
              resolver: undefined,
              restoreMocks: true,
              rootDir: '<homeDir>/Desktop/Repos/monorepo/app/services/api',
              roots: [ '<homeDir>/Desktop/Repos/monorepo/app/services/api' ],
              runner: '<homeDir>/Desktop/Repos/monorepo/node_modules/.pnpm/jest-runner@29.4.3/node_modules/jest-runner/build/index.js',
              runtime: undefined,
              sandboxInjectedGlobals: [],
              setupFiles: [ '<homeDir>/Desktop/Repos/monorepo/app/services/api/jest.setup.ts' ],
              setupFilesAfterEnv: [ '<homeDir>/Desktop/Repos/monorepo/app/services/api/jest.matchers.ts' ],
              skipFilter: false,
              skipNodeResolution: undefined,
              slowTestThreshold: 5,
              snapshotFormat: { escapeString: false, printBasicPrototype: false },
              snapshotResolver: undefined,
              snapshotSerializers: [],
              testEnvironment: '<homeDir>/Desktop/Repos/monorepo/node_modules/.pnpm/jest-environment-node@29.4.3/node_modules/jest-environment-node/build/index.js',
              testEnvironmentOptions: {},
              testLocationInResults: false,
              testMatch: [],
              testPathIgnorePatterns: [ '/node_modules' ],
              testRegex: [ 'src/.*\\.spec\\.[jt]s$' ],
              testRunner: '<homeDir>/Desktop/Repos/monorepo/node_modules/.pnpm/jest-circus@29.4.3/node_modules/jest-circus/runner.js',
              transform: [
                [
                  '^.+\\.(ts|tsx)$',
                  '<homeDir>/Desktop/Repos/monorepo/node_modules/.pnpm/ts-jest@29.0.5_jest@29.4.3/node_modules/ts-jest/dist/index.js',
                  { isolatedModules: true }
                ],
                [ '^.+\\.tsx?$', '<homeDir>/Desktop/Repos/monorepo/node_modules/.pnpm/ts-jest@29.0.5_jest@29.4.3/node_modules/ts-jest/dist/index.js', {} ]
              ],
              transformIgnorePatterns: [ '/node_modules/', '\\.pnp\\.[^\\/]+$' ],
              unmockedModulePathPatterns: undefined,
              watchPathIgnorePatterns: []
            }
          ],
          globalConfig: {
            bail: 0,
            changedFilesWithAncestor: false,
            changedSince: undefined,
            ci: false,
            collectCoverage: false,
            collectCoverageFrom: [],
            coverageDirectory: '<homeDir>/Desktop/Repos/monorepo/app/services/api/coverage',
            coverageProvider: 'babel',
            coverageReporters: [ 'json', 'text', 'lcov', 'clover' ],
            coverageThreshold: undefined,
            detectLeaks: false,
            detectOpenHandles: false,
            errorOnDeprecated: false,
            expand: false,
            filter: undefined,
            findRelatedTests: false,
            forceExit: true,
            globalSetup: undefined,
            globalTeardown: undefined,
            json: false,
            lastCommit: false,
            listTests: false,
            logHeapUsage: true,
            maxConcurrency: 5,
            maxWorkers: 9,
            noSCM: undefined,
            noStackTrace: false,
            nonFlagArgs: undefined,
            notify: false,
            notifyMode: 'failure-change',
            onlyChanged: false,
            onlyFailures: false,
            outputFile: undefined,
            passWithNoTests: false,
            projects: [],
            replname: undefined,
            reporters: [ [ 'default', {} ], [ '<homeDir>/Desktop/Repos/monorepo/node_modules/.pnpm/jest-junit@15.0.0/node_modules/jest-junit/index.js', {} ] ],
            rootDir: '<homeDir>/Desktop/Repos/monorepo/app/services/api',
            runTestsByPath: false,
            seed: -605686201,
            shard: undefined,
            showSeed: undefined,
            silent: undefined,
            skipFilter: false,
            snapshotFormat: { escapeString: false, printBasicPrototype: false },
            testFailureExitCode: 1,
            testNamePattern: undefined,
            testPathPattern: '',
            testResultsProcessor: undefined,
            testSequencer: '<homeDir>/Desktop/Repos/monorepo/node_modules/.pnpm/@jest+test-sequencer@29.4.3/node_modules/@jest/test-sequencer/build/index.js',
            testTimeout: undefined,
            updateSnapshot: 'new',
            useStderr: false,
            verbose: undefined,
            watch: false,
            watchAll: false,
            watchPlugins: undefined,
            watchman: true,
            workerIdleMemoryLimit: 1000000000
          },
          hasDeprecationWarnings: false,
          wallaby: {
            roots: [],
            watchPathIgnorePatterns: [ '/node_modules/', '\\./dist/|\\./build/|\\./coverage/|\\./git/|/\\..+/', '/private/var/folders/ps/4n0jh1l17nd4s9bxcqvvs_xh0000gq/T/jest_dz', '/node_modules', '\\./coverage' ],
            testPathIgnorePatterns: [ '/node_modules/', '\\./dist/|\\./build/|\\./coverage/|\\./git/|/\\..+/', '/private/var/folders/ps/4n0jh1l17nd4s9bxcqvvs_xh0000gq/T/jest_dz', '/node_modules', '\\./coverage' ],
            testMatch: [],
            testRegex: [ 'src/.*\\.spec\\.[jt]s$' ]
          }
        }
      }
    },
    testFramework: { version: 'jest@24.8.0', configurator: 'jest@24.8.0', reporter: 'jest@24.8.0', starter: 'jest@24.8.0', autoDetected: true },
    filesWithCoverageCalculated: [],
    filesWithNoCoverageCalculated: [],
    globalSetup: false,
    dot: true,
    files: [
      { pattern: '/node_modules/', regexp: /\/node_modules\//, ignore: true, trigger: true, load: true, file: true, test: true },
      {
        pattern: '\\./dist/|\\./build/|\\./coverage/|\\./git/|/\\..+/',
        regexp: /\.\/dist\/|\.\/build\/|\.\/coverage\/|\.\/git\/|\/\..+\//,
        ignore: true,
        trigger: true,
        load: true,
        file: true,
        test: true
      },
      {
        pattern: '/private/var/folders/ps/4n0jh1l17nd4s9bxcqvvs_xh0000gq/T/jest_dz',
        regexp: /\/private\/var\/folders\/ps\/4n0jh1l17nd4s9bxcqvvs_xh0000gq\/T\/jest_dz/,
        ignore: true,
        trigger: true,
        load: true,
        file: true,
        test: true
      },
      { pattern: '/node_modules', regexp: /\/node_modules/, ignore: true, trigger: true, load: true, file: true, test: true },
      { pattern: '\\./coverage', regexp: /\.\/coverage/, ignore: true, trigger: true, load: true, file: true, test: true },
      { pattern: '**/**', ignore: false, trigger: true, load: true, order: 1 },
      { pattern: 'src/.*\\.spec\\.[jt]s$', regexp: /src\/.*\.spec\.[jt]s$/, ignore: true, trigger: true, load: true, file: true }
    ],
    tests: [
      { pattern: '/node_modules/', regexp: /\/node_modules\//, ignore: true, trigger: true, load: true, test: true, file: false },
      {
        pattern: '\\./dist/|\\./build/|\\./coverage/|\\./git/|/\\..+/',
        regexp: /\.\/dist\/|\.\/build\/|\.\/coverage\/|\.\/git\/|\/\..+\//,
        ignore: true,
        trigger: true,
        load: true,
        test: true,
        file: false
      },
      {
        pattern: '/private/var/folders/ps/4n0jh1l17nd4s9bxcqvvs_xh0000gq/T/jest_dz',
        regexp: /\/private\/var\/folders\/ps\/4n0jh1l17nd4s9bxcqvvs_xh0000gq\/T\/jest_dz/,
        ignore: true,
        trigger: true,
        load: true,
        test: true,
        file: false
      },
      { pattern: '/node_modules', regexp: /\/node_modules/, ignore: true, trigger: true, load: true, test: true, file: false },
      { pattern: '\\./coverage', regexp: /\.\/coverage/, ignore: true, trigger: true, load: true, test: true, file: false },
      { pattern: 'src/.*\\.spec\\.[jt]s$', regexp: /src\/.*\.spec\.[jt]s$/, ignore: false, trigger: true, load: true, test: true, order: 2 }
    ],
    runAllTestsInAffectedTestFile: false,
    updateNoMoreThanOneSnapshotPerTestFileRun: false,
    compilers: {},
    smartStart: [ { test: true, source: false, pattern: '**/*', startMode: 'open' }, { test: false, source: true, pattern: '**/*', startMode: 'edit' } ],
    logLimits: { inline: { depth: 5, elements: 5000 }, values: { default: { stringLength: 200 }, autoExpand: { elements: 5000, stringLength: 8192, depth: 10 } } },
    preprocessors: {},
    maxConsoleMessagesPerTest: 100,
    autoConsoleLog: true,
    delays: { run: 0, edit: 100, update: 0 },
    workers: { initial: 0, regular: 0, recycle: false },
    teardown: undefined,
    hints: {
      ignoreCoverage: '__REGEXP /ignore coverage|istanbul ignore/',
      ignoreCoverageForFile: '__REGEXP /ignore file coverage/',
      commentAutoLog: '?',
      testFileSelection: { include: '__REGEXP /file\\.only/', exclude: '__REGEXP /file\\.skip/' }
    },
    automaticTestFileSelection: true,
    runSelectedTestsOnly: true,
    mapConsoleMessagesStackTrace: false,
    extensions: {},
    env: {
      type: 'node',
      params: {},
      runner: '<homeDir>/.nvm/versions/node/v16.16.0/bin/node',
      viewportSize: { width: 800, height: 600 },
      options: { width: 800, height: 600 },
      bundle: true
    },
    reportUnhandledPromises: true,
    slowTestThreshold: 75,
    lowCoverageThreshold: 80,
    runAllTestsWhenNoAffectedTests: false,
    configCode: 'auto.detect#-475307777',
    testLocations: [ 'src/apps/redirects/routes/updateRedirect/poc.acceptance.spec.ts' ]
  },
  packageJSON: {
    dependencies: {
      '@google-cloud/bigquery': '5.9.0',
      '@google-cloud/datastore': '6.2.0',
      '@google-cloud/pubsub': '2.6.0',
      '@google-cloud/storage': '5.4.0',
      '@hapi/boom': '9.1.4',
      '@hapi/hapi': '20.2.1',
      '@hapi/nes': '12.0.4',
      '@sendgrid/client': '6.3.0',
      '@sendgrid/mail': '7.2.2',
      '@sy/auth': 'workspace:*',
      '@sy/content-security-policy': 'workspace:*',
      '@sy/logger': 'workspace:*',
      '@workos-inc/node': '2.4.0',
      'accept-language': '3.0.18',
      'accept-language-parser': '1.5.0',
      'analytics-node': '4.0.1',
      'assert-process-env': '1.0.0',
      blankie: '4.1.0',
      boom: '7.2.0',
      'circular-json': '0.5.9',
      cloudinary: '1.26.3',
      'crypto-random-string': '3.2.0',
      eventemitter3: '3.1.0',
      'fast-csv': '4.3.6',
      fontkit: '1.8.1',
      googleapis: '42.0.0',
      h2o2: '8.1.2',
      handlebars: '4.7.7',
      hoek: '6.1.2',
      inert: '5.1.0',
      ioredis: '4.26.0',
      jimp: '0.16.1',
      joi: '13.0.2',
      jsonwebtoken: '7.2.1',
      'launchdarkly-node-server-sdk': '7.0.0',
      lodash: '4.17.21',
      lout: '11.2.3',
      'module-alias': '2.2.2',
      moment: '2.24.0',
      newrelic: '7.5.2',
      'node-ws-reconnect': '2.0.0',
      'oauth-1.0a': '2.2.6',
      opossum: '6.3.0',
      pg: '8.7.3',
      'pg-hstore': '2.3.4',
      'pusher-js': '7.0.2',
      q: '1.5.1',
      redlock: '4.2.0',
      request: '2.88.0',
      requestretry: '2.0.2',
      scooter: '5.0.1',
      semver: '7.3.5',
      sequelize: '6.28.0',
      'serialize-error': '3.0.0',
      'slack-node': '0.1.8',
      speakeasy: '2.0.0',
      'stream-chat': '3.7.0',
      stripe: '8.193.0',
      tsd: '0.20.0',
      uuid: '3.1.0',
      vision: '5.3.3',
      wreck: '14.1.0',
      ws: '6.1.4'
    },
    devDependencies: {
      '@sinonjs/fake-timers': '9.1.2',
      '@types/babel__core': '7.1.19',
      '@types/boom': '7.3.1',
      '@types/hapi__hapi': '20.0.10',
      '@types/ioredis': '4.28.10',
      '@types/jest': '29.4.0',
      '@types/jest-when': '3.5.2',
      '@types/joi': '14.3.4',
      '@types/jsonwebtoken': '8.5.8',
      '@types/lodash': '4.14.176',
      '@types/newrelic': '7.0.3',
      '@types/node': '16.11.6',
      '@types/requestretry': '1.12.8',
      '@types/sinonjs__fake-timers': '8.1.2',
      '@types/superagent': '4.1.15',
      '@types/supertest': '2.0.11',
      dotenv: '10.0.0',
      isemail: '3.2.0',
      'jest-when': '3.5.2',
      'lint-staged': '12.3.7',
      micromatch: '4.0.4',
      'mock-fs': '5.1.2',
      'mocked-env': '1.3.5',
      'npm-run-all': '4.1.5',
      rimraf: '3.0.2',
      'sequelize-cli': '6.4.1',
      sinon: '11.1.2',
      superagent: '6.1.0',
      supertest: '6.1.6',
      'ts-node': '10.9.1',
      'ts-node-dev': 'git+ssh://git@github.com:monorepo/ts-node-dev#421eadc2e9568ad3c4c68e2edf35d4b7fd6135b9',
      typescript: '4.4.2'
    }
  },
  fs: { numberOfFiles: 1404 },
  debug: [
    '2023-03-06T08:42:39.890Z config Attempting automatic configuration for angular\n',
    '2023-03-06T08:42:39.909Z angular/cli config Angular CLI not found.\n',
    '2023-03-06T08:42:39.909Z config Finished attempting automatic configuration for angular (20ms)\n',
    '2023-03-06T08:42:39.909Z config Attempting automatic configuration for jest\n',
    '2023-03-06T08:42:40.087Z jest/config Detected Jest.\n',
    '2023-03-06T08:42:40.087Z jest/config Configured Jest.\n',
    '2023-03-06T08:42:40.087Z config Finished attempting automatic configuration for jest (178ms)\n',
    '2023-03-06T08:42:40.088Z project Wallaby Node version: v16.16.0\n',
    '2023-03-06T08:42:40.088Z project Wallaby config: <homeDir>/Desktop/Repos/monorepo/app/services/api/auto.detect\n',
    '2023-03-06T08:42:40.105Z fs File system starting\n',
    '2023-03-06T08:42:40.507Z fs File system scan completed\n',
    '2023-03-06T08:42:40.580Z project File cache: <homeDir>/.vscode/extensions/wallabyjs.wallaby-vscode-1.0.350/projects/9d58574492a7a9a1_1\n',
    '2023-03-06T08:42:40.586Z uiService Listening port 51236\n',
    '2023-03-06T08:42:40.621Z workers Parallelism for initial run: 8, for regular run: 4\n',
    '2023-03-06T08:42:40.621Z workers Starting run worker instance #0\n',
    '2023-03-06T08:42:40.622Z workers Starting run worker instance #1\n',
    '2023-03-06T08:42:40.622Z workers Starting run worker instance #2\n',
    '2023-03-06T08:42:40.622Z workers Starting run worker instance #3\n',
    '2023-03-06T08:42:40.622Z workers Starting run worker instance #4\n',
    '2023-03-06T08:42:40.622Z workers Starting run worker instance #5\n',
    '2023-03-06T08:42:40.622Z workers Starting run worker instance #6\n',
    '2023-03-06T08:42:40.622Z workers Starting run worker instance #7\n',
    '2023-03-06T08:42:40.631Z workers Web server is listening at 62370\n',
    '2023-03-06T08:42:40.697Z project Stopping process pool\n',
    '2023-03-06T08:42:40.697Z project File cache is up-to-date, starting full test run\n',
    '2023-03-06T08:42:40.732Z project Test run started; run priority: 3\n',
    '2023-03-06T08:42:40.743Z project Running all tests\n',
    '2023-03-06T08:42:40.760Z project Test run finished\n',
    '2023-03-06T08:42:40.760Z project Test run data re-queued\n',
    '2023-03-06T08:42:40.845Z project Requested to run all tests\n',
    '2023-03-06T08:42:40.847Z project Test run started; run priority: 3\n',
    '2023-03-06T08:42:40.847Z project Running all tests\n',
    '2023-03-06T08:42:40.896Z workers Starting test run, priority: 3\n',
    '2023-03-06T08:42:40.896Z nodeRunner Starting sandbox [worker #0, session #b9uak]\n',
    '2023-03-06T08:42:40.896Z nodeRunner Preparing sandbox [worker #0, session #b9uak]\n',
    '2023-03-06T08:42:40.909Z workers Started run worker instance (delayed) #2\n',
    '2023-03-06T08:42:40.929Z workers Started run worker instance (delayed) #0\n',
    '2023-03-06T08:42:40.929Z nodeRunner Prepared sandbox [worker #0, session #b9uak]\n',
    '2023-03-06T08:42:40.929Z workers [worker #0, session #b9uak] Running tests in sandbox\n',
    '2023-03-06T08:42:40.932Z workers Started run worker instance (delayed) #1\n',
    '2023-03-06T08:42:40.943Z workers Started run worker instance (delayed) #4\n',
    '2023-03-06T08:42:40.949Z workers Started run worker instance (delayed) #3\n',
    '2023-03-06T08:42:40.983Z workers Started run worker instance (delayed) #7\n',
    '2023-03-06T08:42:40.988Z workers Started run worker instance (delayed) #6\n',
    '2023-03-06T08:42:40.993Z workers Started run worker instance (delayed) #5\n',
    '2023-03-06T08:42:41.979Z workers Scheduling Jest Test Run (b9uak): 2023-03-06T08:42:41.883Z\n',
    '2023-03-06T08:42:41.981Z workers Sandbox (active) [b9uak] error: Farm is ended, no more calls can be done to it\n' +
      '    at Worker._callFunctionWithArgs (<homeDir>/Desktop/Repos/monorepo/node_modules/.pnpm/jest-worker@29.4.3/node_modules/jest-worker/build/index.js:159:13)\n' +
      '    at <homeDir>/Desktop/Repos/monorepo/node_modules/.pnpm/jest-runner@29.4.3/node_modules/jest-runner/build/index.js:155:32\n',
    '2023-03-06T08:42:41.982Z workers [b9uak] Run 0 test(s), skipped 0 test(s)\n',
    '2023-03-06T08:42:41.983Z workers [b9uak] Sandbox is responsive, closing it\n',
    '2023-03-06T08:42:41.984Z workers Failed to map the stack to user code, entry message: Farm is ended, no more calls can be done to it, stack: Error: Farm is ended, no more calls can be done to it\n' +
      '    at Worker._callFunctionWithArgs (<homeDir>/Desktop/Repos/monorepo/node_modules/.pnpm/jest-worker@29.4.3/node_modules/jest-worker/build/index.js:159:13)\n' +
      '    at <homeDir>/Desktop/Repos/monorepo/node_modules/.pnpm/jest-runner@29.4.3/node_modules/jest-runner/build/index.js:155:32\n',
    '2023-03-06T08:42:41.985Z project Test run finished\n',
    '2023-03-06T08:42:41.986Z project Processed console.log entries\n',
    '2023-03-06T08:42:41.986Z project Processed loading sequences\n',
    '2023-03-06T08:42:41.986Z project Processed executed tests\n',
    '2023-03-06T08:42:41.990Z project Processed code coverage\n',
    '2023-03-06T08:42:42.012Z project Test run result processed and sent to IDE\n'
  ]
}
smcenlly commented 1 year ago

Thanks for reporting the problem. We believe your problem is from using the workerIdleMemoryLimit setting in your jest configuration. This forces jest to run your tests in worker threads, which does not work with Wallaby. Wallaby already parallelizes your test run in its own worker processes, so running in worker threads should not be necessary.

We've updated Wallaby to ignore this setting, which we believe will fix your problem.

Please update to the latest version of Wallaby core, v1.0.1391.


If for some reason you are still having problems after updating, could you please create a small sample repo with the same structure and jest configuration as your project with a sample test that breaks in the same way?