Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pa11y CI hangs when passing browser/page in config #248

Open
aarongoldenthal opened this issue Oct 10, 2024 · 0 comments
Open

Pa11y CI hangs when passing browser/page in config #248

aarongoldenthal opened this issue Oct 10, 2024 · 0 comments

Comments

@aarongoldenthal
Copy link
Contributor

When passing in a browser (and page) object in config, for example as a workaround to #237, pa11y-ci completes the analysis successfully, but then hangs.

For example:

.pa11yci-dark.js

"use strict";

const puppeteer = require("puppeteer");

const getContext = async () => {
	const browser = await puppeteer.launch({});
	const page = await browser.newPage();
	await page.emulateMediaFeatures([
		{ name: "prefers-color-scheme", value: "dark" },
	]);
	return { browser, page };
};

const context = getContext().then((c) => c);

module.exports = {
	defaults: {
		browser: context.browser,
		page: context.page,
	},
};

(this is a Windows 11 example, but occurs in Linux as well)

PS C:\pa11y-ci> node ./bin/pa11y-ci.js -c .pa11yci-dark.js https://github.com

Running Pa11y on 1 URLs:
 > https://github.com/ - 5 errors

... (details for 5 errors)
... (process hangs until killed)

There are a couple of issues:

  • The primary issue is that the config is passed to pa11y, and properly handled there, but all of the browser logic in pa11y-ci is completely separate from pa11y. For example, in this case here pa11y-ci will open an unnecessary browser that is never used, and there's no way to manage the browser from config.
  • Because the browser is opened in config there's no way to close it. At the end of the run the exitCode is set to one of 3 values here, and that lgoic is executed, but that doesn't force the process to exit. If these are changed to calls to exit() with the appropriate exit code it does for the process to exit.
aarongoldenthal added a commit to aarongoldenthal/pa11y-ci that referenced this issue Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant