karma-runner / karma-firefox-launcher

A Karma plugin. Launcher for Firefox.
MIT License
104 stars 54 forks source link

FirefoxHeadless is not captured in containered GitHub action with node 16 #245

Open MatthijsBurgh opened 1 year ago

MatthijsBurgh commented 1 year ago

I am using karma in combination with grunt. Running the tests work fine on my machine(node 16), docker(locally, node 16) and containered GH action(node 14), but when running in containered GH action with node 16, it fails to start Firefox. It happens both in ubuntu 18 and 20.

The version of the Firefox apt package: 105.0+build2-0ubuntu0.20.04.1

The log (src):

unning "karma:test" (karma) task
01 11 2022 10:29:57.950:DEBUG [config]: Loading config /__w/roslibjs/roslibjs/test/karma.conf.js
01 11 2022 10:29:57.953:DEBUG [config]: autoWatch set to false, because of singleRun
01 11 2022 10:29:57.955:DEBUG [karma-server]: Final config Config {
  LOG_DISABLE: 'OFF',
  LOG_ERROR: 'ERROR',
  LOG_WARN: 'WARN',
  LOG_INFO: 'INFO',
  LOG_DEBUG: 'DEBUG',
  frameworks: [ 'mocha', 'chai' ],
  protocol: 'http:',
  port: 9876,
  listenAddress: '0.0.0.0',
  hostname: 'localhost',
  httpsServerConfig: {},
  basePath: '/__w/roslibjs/roslibjs/test',
  files: [
    Pattern {
      pattern: '/__w/roslibjs/roslibjs/node_modules/eventemitter2/lib/eventemitter2.js',
      served: true,
      included: true,
      watched: true,
      nocache: false,
      weight: [ 1, 0, 0, 0, 0, 0 ],
      type: undefined,
      isBinary: undefined,
      integrity: undefined
    },
    Pattern {
      pattern: '/__w/roslibjs/roslibjs/node_modules/cbor-js/cbor.js',
      served: true,
      included: true,
      watched: true,
      nocache: false,
      weight: [ 1, 0, 0, 0, 0, 0 ],
      type: undefined,
      isBinary: undefined,
      integrity: undefined
    },
    Pattern {
      pattern: '/__w/roslibjs/roslibjs/src/util/cborTypedArrayTags.js',
      served: true,
      included: true,
      watched: true,
      nocache: false,
      weight: [ 1, 0, 0, 0, 0, 0 ],
      type: undefined,
      isBinary: undefined,
      integrity: undefined
    },
    Pattern {
      pattern: '/__w/roslibjs/roslibjs/build/roslib.js',
      served: true,
      included: true,
      watched: true,
      nocache: false,
      weight: [ 1, 0, 0, 0, 0, 0 ],
      type: undefined,
      isBinary: undefined,
      integrity: undefined
    },
    Pattern {
      pattern: '/__w/roslibjs/roslibjs/test/require-shim.js',
      served: true,
      included: true,
      watched: true,
      nocache: false,
      weight: [ 1, 0, 0, 0, 0, 0 ],
      type: undefined,
      isBinary: undefined,
      integrity: undefined
    },
    Pattern {
      pattern: '/__w/roslibjs/roslibjs/test/*.test.js',
      served: true,
      included: true,
      watched: true,
      nocache: false,
      weight: [ 1, 0, 1, 0, 0, 0 ],
      type: undefined,
      isBinary: undefined,
      integrity: undefined
    }
  ],
  browserConsoleLogOptions: { level: 'debug', format: '%b %T: %m', terminal: true },
  customContextFile: null,
  customDebugFile: null,
  customClientContextFile: null,
  exclude: [ '/__w/roslibjs/roslibjs/test/karma.conf.js' ],
  logLevel: 'ALL',
  colors: true,
  autoWatch: false,
  autoWatchBatchDelay: 250,
  restartOnFileChange: false,
  usePolling: true,
  reporters: [ 'progress' ],
  singleRun: true,
  browsers: [ 'FirefoxHeadless' ],
  captureTimeout: 60000,
  pingTimeout: 5000,
  proxies: {},
  proxyValidateSSL: true,
  preprocessors: [Object: null prototype] {},
  preprocessor_priority: {},
  urlRoot: '/',
  upstreamProxy: undefined,
  reportSlowerThan: 0,
  loggers: [
    {
      type: 'console',
      layout: { type: 'pattern', pattern: '%[%d{DATETIME}:%p [%c]: %]%m' }
    }
  ],
  transports: [ 'polling', 'websocket' ],
  forceJSONP: false,
  plugins: [ 'karma-*' ],
  client: {
    args: [],
    useIframe: true,
    runInParent: false,
    captureConsole: true,
    clearContext: true,
    allowedReturnUrlPatterns: [ '^https?://' ],
    mocha: { timeout: 10000 }
  },
  defaultClient: {
    args: [],
    useIframe: true,
    runInParent: false,
    captureConsole: true,
    clearContext: true,
    allowedReturnUrlPatterns: [ '^https?://' ],
    mocha: { timeout: 10000 }
  },
  browserDisconnectTimeout: 2000,
  browserDisconnectTolerance: 0,
  browserNoActivityTimeout: 30000,
  processKillTimeout: 2000,
  concurrency: Infinity,
  failOnEmptyTestSuite: true,
  retryLimit: 2,
  detached: false,
  crossOriginAttribute: true,
  browserSocketTimeout: 20000,
  background: false,
  configFile: '/__w/roslibjs/roslibjs/test/karma.conf.js',
  runnerPort: 9200
}
01 11 [202](https://github.com/RobotWebTools/roslibjs/actions/runs/3368672977/jobs/5587483389#step:7:203)2 10:29:57.955:DEBUG [plugin]: Loading karma-* from /__w/roslibjs/roslibjs/node_modules
01 11 2022 10:29:57.961:DEBUG [plugin]: Loading plugin /__w/roslibjs/roslibjs/node_modules/karma-chai.
01 11 2022 10:29:57.962:DEBUG [plugin]: Loading plugin /__w/roslibjs/roslibjs/node_modules/karma-firefox-launcher.
01 11 2022 10:29:57.964:DEBUG [plugin]: Loading plugin /__w/roslibjs/roslibjs/node_modules/karma-mocha.
01 11 2022 10:29:57.969:DEBUG [web-server]: Instantiating middleware
01 11 2022 10:29:57.993:INFO [karma-server]: Karma v6.4.0 server started at http://localhost:9876/
01 11 2022 10:29:57.994:INFO [launcher]: Launching browsers FirefoxHeadless with concurrency unlimited
01 11 2022 10:29:57.997:INFO [launcher]: Starting browser FirefoxHeadless
01 11 2022 10:29:57.997:DEBUG [launcher]: null -> BEING_CAPTURED
01 11 2022 10:29:57.998:DEBUG [temp-dir]: Creating temp dir at /tmp/karma-69133750
01 11 2022 10:29:57.999:DEBUG [launcher]: firefox http://localhost:9876/?id=69133750 -profile /tmp/karma-69133750 -no-remote -wait-for-browser -headless --start-debugger-server 6000
01 11 2022 10:30:57.998:WARN [launcher]: FirefoxHeadless has not captured in 60000 ms, killing.
01 11 2022 10:30:57.999:DEBUG [launcher]: BEING_CAPTURED -> BEING_KILLED
01 11 2022 10:30:58.024:DEBUG [launcher]: Process FirefoxHeadless exited with code null and signal SIGTERM
01 11 2022 10:30:58.024:DEBUG [temp-dir]: Cleaning temp dir /tmp/karma-691[337](https://github.com/RobotWebTools/roslibjs/actions/runs/3368672977/jobs/5587483389#step:7:338)50
01 11 2022 10:30:58.027:INFO [launcher]: Trying to start FirefoxHeadless again (1/2).
01 11 2022 10:30:58.027:DEBUG [launcher]: BEING_KILLED -> RESTARTING
01 11 2022 10:30:58.027:DEBUG [launcher]: RESTARTING -> FINISHED
01 11 2022 10:30:58.027:DEBUG [launcher]: FINISHED -> FINISHED
01 11 2022 10:30:58.027:DEBUG [launcher]: Restarting FirefoxHeadless
01 11 2022 10:30:58.027:DEBUG [launcher]: FINISHED -> BEING_CAPTURED
01 11 2022 10:30:58.027:DEBUG [temp-dir]: Creating temp dir at /tmp/karma-69133750
01 11 2022 10:30:58.028:DEBUG [launcher]: firefox http://localhost:9876/?id=69133750 -profile /tmp/karma-69133750 -no-remote -wait-for-browser -headless --start-debugger-server 6000
01 11 2022 10:31:58.028:WARN [launcher]: FirefoxHeadless has not captured in 60000 ms, killing.
01 11 2022 10:31:58.029:DEBUG [launcher]: BEING_CAPTURED -> BEING_KILLED
01 11 2022 10:31:58.048:DEBUG [launcher]: Process FirefoxHeadless exited with code null and signal SIGTERM
01 11 2022 10:31:58.049:DEBUG [temp-dir]: Cleaning temp dir /tmp/karma-69133750
01 11 2022 10:31:58.051:INFO [launcher]: Trying to start FirefoxHeadless again (2/2).
01 11 2022 10:31:58.051:DEBUG [launcher]: BEING_KILLED -> RESTARTING
01 11 2022 10:31:58.051:DEBUG [launcher]: RESTARTING -> FINISHED
01 11 2022 10:31:58.051:DEBUG [launcher]: FINISHED -> FINISHED
01 11 2022 10:31:58.051:DEBUG [launcher]: Restarting FirefoxHeadless
01 11 2022 10:31:58.051:DEBUG [launcher]: FINISHED -> BEING_CAPTURED
01 11 2022 10:31:58.051:DEBUG [temp-dir]: Creating temp dir at /tmp/karma-69133750
01 11 2022 10:31:58.052:DEBUG [launcher]: firefox http://localhost:9876/?id=69133750 -profile /tmp/karma-69133750 -no-remote -wait-for-browser -headless --start-debugger-server 6000
01 11 2022 10:32:58.052:WARN [launcher]: FirefoxHeadless has not captured in 60000 ms, killing.
01 11 2022 10:32:58.053:DEBUG [launcher]: BEING_CAPTURED -> BEING_KILLED
01 11 2022 10:32:58.072:DEBUG [launcher]: Process FirefoxHeadless exited with code null and signal SIGTERM
01 11 2022 10:32:58.073:DEBUG [temp-dir]: Cleaning temp dir /tmp/karma-69133750
01 11 2022 10:32:58.075:ERROR [launcher]: FirefoxHeadless failed 2 times (timeout). Giving up.
01 11 2022 10:32:58.075:DEBUG [karma-server]: Run complete, exiting.
01 11 2022 10:32:58.076:DEBUG [launcher]: Disconnecting all browsers
01 11 2022 10:32:58.076:DEBUG [launcher]: BEING_KILLED -> BEING_FORCE_KILLED
01 11 2022 10:32:58.076:DEBUG [proxy]: Destroying proxy agents
01 11 2022 10:32:58.077:DEBUG [launcher]: BEING_FORCE_KILLED -> FINISHED
01 11 2022 10:32:58.077:DEBUG [launcher]: FINISHED -> FINISHED
Warning: Task "karma:test" failed. Use --force to continue.
birtles commented 1 year ago

Thanks for this report. Unfortunately I don't know anything about containered GitHub actions and I don't have any idea what might be going wrong based on the log. Sorry!

alexgibson commented 1 year ago

We're also seeing this issue happening across multiple repositories. The error doesn't seem specific to a particular Node version running in the container, at least from my testing.

I'm still investigating, but https://github.com/actions/runner-images/issues/6704 could be related.

Downgrading our image to ubuntu-20.04 seems to fix the issue temporarily.

kemsky commented 1 year ago

@birtles, on my desktop PC (Ubuntu 22.04) it also does not work, so it basically does not work in Ubuntu.

Playwright had similar problem: https://github.com/microsoft/playwright/issues/20555

birtles commented 1 year ago

It works for me on Node 16 with ubuntu-latest in a regular GitHub action. I've never used a contained GitHub action, I'm afraid.

iamart commented 1 year ago

Same issue in aws ec2; on Ubuntu 22.04.2 LTS. Quite interesting, but it works fine in CircleCI's cimg/node:16.18-browsers which is based on ubuntu 22.04.1 LTS.