Page MenuHomePhabricator

Error running Karma tests locally
Open, Needs TriagePublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

What happens?:

Running "karma:main" (karma) task
(node:43356) Warning: Accessing non-existent property 'VERSION' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
19 07 2023 13:59:32.275:INFO [karma-server]: Karma v6.3.20 server started at http://localhost:9876/
19 07 2023 13:59:32.276:INFO [launcher]: Launching browsers ChromeCustom with concurrency unlimited
19 07 2023 13:59:32.280:INFO [launcher]: Starting browser ChromeHeadless
19 07 2023 13:59:32.353:ERROR [launcher]: Cannot start ChromeHeadless
	[0719/135932.348118:ERROR:headless_shell.cc(250)] Multiple targets are not supported.

19 07 2023 13:59:32.353:ERROR [launcher]: ChromeHeadless stdout:
19 07 2023 13:59:32.353:ERROR [launcher]: ChromeHeadless stderr: [0719/135932.348118:ERROR:headless_shell.cc(250)] Multiple targets are not supported.

19 07 2023 13:59:32.354:INFO [launcher]: Trying to start ChromeHeadless again (1/2).
19 07 2023 13:59:32.377:ERROR [launcher]: Cannot start ChromeHeadless
	[0719/135932.376425:ERROR:headless_shell.cc(250)] Multiple targets are not supported.

19 07 2023 13:59:32.377:ERROR [launcher]: ChromeHeadless stdout:
19 07 2023 13:59:32.377:ERROR [launcher]: ChromeHeadless stderr: [0719/135932.376425:ERROR:headless_shell.cc(250)] Multiple targets are not supported.

19 07 2023 13:59:32.378:INFO [launcher]: Trying to start ChromeHeadless again (2/2).
19 07 2023 13:59:32.402:ERROR [launcher]: Cannot start ChromeHeadless
	[0719/135932.400743:ERROR:headless_shell.cc(250)] Multiple targets are not supported.

19 07 2023 13:59:32.402:ERROR [launcher]: ChromeHeadless stdout:
19 07 2023 13:59:32.402:ERROR [launcher]: ChromeHeadless stderr: [0719/135932.400743:ERROR:headless_shell.cc(250)] Multiple targets are not supported.

19 07 2023 13:59:32.402:ERROR [launcher]: ChromeHeadless failed 2 times (cannot start). Giving up.

What should have happened instead?:
Tests should run successfully.

Software version (skip for WMF-hosted wikis like Wikipedia):
Mac OS Ventura
Node v16.19.0
PHP v8.2.1

Other information (browser name/version, screenshots, etc.):

Screenshot 2023-07-19 at 2.03.29 PM.png (2,024×1,854 px, 893 KB)

Seems like this may be related to https://phabricator.wikimedia.org/T335329#8803718

Event Timeline

I was able to get the Karma tests to run by removing some config located at GruntFile.js L409.

The current settings are:

karma: {
    options: {
        customLaunchers: {
            ChromeCustom: {
                base: 'ChromeHeadless',
                    // Chrome requires --no-sandbox in Docker/CI.
                    // WMF CI images expose CHROMIUM_FLAGS which sets that.
                    flags: ( process.env.CHROMIUM_FLAGS || '' ).split( ' ' )
                }
            },
        //...
        }
    }
}

Removing flags: ( process.env.CHROMIUM_FLAGS || '' ).split( ' ' ) allowed the Karma tests to run normally (though a phan test still failed for some reason after this...)

I think that CI images are using an older version of headless Chrome that needs to be configured in a now-obsolete way, and this is causing things to fail when attempting to run locally with a more recent version.

I'm not super familiar with Karma, this particular "ChromeHeadless" configuration, or how this is handled in CI. Is there a change we can make in OOUI to specify which version of Chrome/Chromium should be used for these tests?

hashar subscribed.

That was previously noticed in PageTriage via T335329. We have found the same issue in MediaWiki while attempting to upgrade Chromium: T366799

The issue is since version 110, Chrome no more accepts multiple arguments when run with --headless.

Fresnel uses a split:

	const launchOpts = ( process.env.CHROMIUM_FLAGS ) ?
		{ args: process.env.CHROMIUM_FLAGS.split( /\s+/ ) } :
		{};