-
Notifications
You must be signed in to change notification settings - Fork 69
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
axe-core-npm and axe-puppeteer silently hung when testing a page #675
Comments
I've searched other issues here and wasn't able to find similar problems, even tried the solution mentioned in #230 as it is about "stucked CLi", didn't help... |
And this is the minimum code that I used to reproduce the hung axe locally (or with URL);
(nothing special here, I guess) |
Chrome extension (axe-core 4.6.3) on same page worked, but triggered a console error (I don't know if it may be related):
Digging into minified bundle and this seems to be the source of the console message;
|
Apologies for not responding to this earlier, seems I missed it. I think I coincidentally fixed this issue in axe-core just the other day. Hopefully that means in the next release of axe-core this issue should be fixed. If you wanted to try it out you should be able to install const { AxePuppeteer } = require('@axe-core/puppeteer');
const puppeteer = require('puppeteer');
const fs = require('fs');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setBypassCSP(true);
const contentHtml = fs.readFileSync('example.html', 'utf8');
await page.setContent(contentHtml);
const axeSource = fs.readFileSync(require.resolve('axe-core'));
const results = await new AxePuppeteer(page, axeSource).analyze();
console.log(results);
await page.close();
await browser.close();
})(); |
No problem, thank you. Will check the |
Tried now, seems like puppeteer can't serialize the function;
Used code from your example (#675 (comment)) as runtime... I've tried with different versions, stable and next, and got same problem with all. Last dependency tree:
Any ideas? Can you please share your dependency tree with versions? |
This is working for me const { AxePuppeteer } = require('@axe-core/puppeteer');
const puppeteer = require('puppeteer');
const { promises: fs } = require('fs');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
const axeSource = await fs.readFile(require.resolve('axe-core'), 'utf8');
await page.setContent(`
<html lang="en">
<head>
<title>Test Page</title>
</head>
<body>
<main>
<h1>Hello World</h1>
<button id="empty-button"></button>
<iframe title="iframe" srcdoc="<button id='iframe-empty-button'></button>"></iframe>
</main>
</body>
</html>
`);
const results = await new AxePuppeteer(page, axeSource).analyze();
console.log(results.violations);
// console.log(results.violations[0].nodes);
await page.close();
await browser.close();
})(); And here's my dependencies: "devDependencies": {
"@axe-core/puppeteer": "^4.6.0",
"axe-core": "^4.6.3-canary.f029271",
"puppeteer": "^18.2.1"
} |
Might be I forgot the |
Just tested with exactly the same dependencies and code and your example worked fine. But when testing with my HTML it is the same - things are just stucked, no output whatsoever.
Any tips on how to debug what is happening in analyze()? To find out where it gets stucked? I am quite sure that HTML I want to test is the cause. It has a lot of iframes with videos and is quite complex and not valid, but would anticipate that analyze() would give up within some reasonable / configured timeout instead of getting blocked with no output... |
I'd start with opening the page in headed mode ( If the |
Hi thanks for advice and patience. Unfortunately I can not share the HTML or URL (NDA...) and I know that it makes things difficult. Thanks for understanding. I've tried with headed mode and yes, there are a lot of errors and warnings in the console, but none of them comes from axe. Most of them are CSP related and some are just JS complaining because of missing elements that are supposed to have events on them (undefined...). Then I tried injecting the axe on the page and running it manually as you suggested and it worked without problems. Got the results back and all was good (testEngine: {name: 'axe-core', version: '4.6.3-canary.235e632'}) So I wondered if I can maybe just remove all iframes and run the axe-puppeteer as originally planned. It worked. Axe returned results as desired. I've just used this code:
I wanted to know if problem lies in specific iframes - I suspected the cookie consent provider as their solution is quite complex... It wasn't the cause. After some try and fail I removed all Google maps iframes ( So obviously the problem lies in Google maps iframes for this site. Site has at least 20 of them, lazy loaded, but still. I would still expect that axe would not be blocked in such cases though. Or that it would timeout as mentioned in my bypass (#675 (comment)). Will try to make a simple test case that will re-create the situation with iframes and won't be proprietary... |
@straker - sorry for long delay. Found similar issue on a random site I can share here and maybe you can check it out. Tried with axe-core 4.7.0 in Puppeteer and it often fails the same way - as before mentioned problem. Using axe extension using same core version (4.7.0) seem to work, but browser console reports Single iframe on the page is again Google maps (with |
@BogdanCerovac Thanks for the link. I'll check it out and see if I can find anything. |
Alright. I found the issue (at least with the page you gave me). There's an iframe on the page with |
Thank you @straker. This worked OK. I've just made a simple check before scrolling to the bottom;
|
Product: cli & puppeteer
I've stumbled upon a case when axe-core-npm (triggered via CLI) and axe-puppeteer silently hangs and I have to manually kill them.
I've copied source HTML to local file and it stucks there as well. I've been using latest versions of both.
Same page tested with browser extension went through but caused some warnings and errors in the console.
Unfortunately I can't reveal the URL/provide HTML because of NDA, but wonder if I can do some more debugging locally (I've tried --verbose in the CLI and I didn't find any options for verbose output via axe-puppeteer, maybe that would be a great start if it's possible).
I was hoping to find a mechanism in axe documentation that would timeout hung analyzes, but couldn't find any - so I decided to make a temporary solution. Please correct me if I am wrong - is there a way to timeout and throw an error if analyze is hung?
Simple temporary fix for the Puppeteer scenario - using Promise.any - that could maybe be useful for somebody.
It isn't perfect and it can introduce memory leaks if axe will hung multiple times, but it saved my problem when only a single URL was problematic.
Desired behavior would be to timeout with throwing an error, I think. That would at least make it possible for me to use in try&catch and handle situation manually. My temporary fix could maybe do the cleanup if it could also "kill" the hung analyze...
Expectation: axe should not hung, it should report an error, at least timeout
Actual: It silently hangs. In the CLI output (
axe --timer --verbose --timeout=120 https://....
) last lines were:Motivation: I think this can be a problem in CD/CI pipelines and also when checking things in bulk. Axe should timeout with an error that could be caught. I would also appreciate some info about the cause being displayed, so that I could fix the webpage / inform the owner about problems, if possible...
The text was updated successfully, but these errors were encountered: