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

[BUG]: Latest version 3.1.41 throws an error and crashes #1149

Closed
carlosparreno opened this issue Nov 9, 2022 · 24 comments
Closed

[BUG]: Latest version 3.1.41 throws an error and crashes #1149

carlosparreno opened this issue Nov 9, 2022 · 24 comments
Assignees
Labels
Bug Something isn't working Ready for QA user-reported Issues identified outside of the core team

Comments

@carlosparreno
Copy link

Project

a11y checker engine

Browser

Chrome, Safari, Firefox

Operating system

MacOS, Other

Description

  • We use the accessibility checker in a React project.

  • We are using version "^3.1.40" that automatically picks up any new minor/patch version.

  • Since the time version 3.1.41 has been released our accessibility tests fail with the following error:
    Error: Cannot find module '@babel/runtime-corejs3/helpers/interopRequireDefault' from '../../../../../tmp/accessibility-checker/engine/ace-node.js'

  • When we fixate the version to be 3.1.40 the error is not reproducible any longer.

  • Additionally I add here how we use accessibility-checker. All components are used with the following function:

  /**
   * Runs the accessibility scan and on failure, outputs the results.
   */

async function runAAT(component, label) {
    const validateComponent = async () => {
      const results = await AAT.getCompliance(component, label);
      if (AAT.assertCompliance(results.report) === 0) {
        return true;
      }
      return false;
    };
    const a11yValidation = await validateComponent();
    if (a11yValidation === true) {
      fs.unlinkSync(`${process.env.PWD}/results/a11y/${label}.json`);
    }
    return a11yValidation;
  }

Steps to reproduce

  1. Install "accessiblity-checker": 3.1.41.
  2. Have tests using the getCompliance and assertCompliance functions.
  3. Error is thrown:

Screenshot 2022-11-09 at 16 26 29

And after this initial error.... every test fails with the following error message:

Screenshot 2022-11-09 at 16 26 45

@tombrunet
Copy link
Member

tombrunet commented Nov 9, 2022

Quick test on our end had no failure. We don't have any imports in the ace-node.js file - you can open https://unpkg.com/accessibility-checker-engine@3.1.41/ace-node.js and search and see that that @babel is not referenced anywhere. I'll try to run through some of our boilerplates to see if there's some react combination that's triggering that, but it seems like something in your environment is injecting into that file. Can you possibly include a copy of your ace-node.js file so we can compare against the original?

@carlosparreno
Copy link
Author

Hi @tombrunet,

I'm using accessibility-checker package, not the mentioned accessibility-checker-engine, not sure if we are talking about different packages that you guys provide.

I'm not able to find the ace-node.js file in the node_modules/accessibility-checker. See following image:

Screenshot 2022-11-09 at 17 41 09

The error reported seems to be in a tmp folder created by ACEngineManager.js as per my understanding.

Am I making sense?

@tombrunet
Copy link
Member

accessibility-checker fetches the accessibility-checker-engine and writes it to that tmp folder so that it can load the engine and run it. If you look at the contents of that file in the /tmp folder, it should match that from unpkg.

@carlosparreno
Copy link
Author

Thanks @tombrunet. So, I was able to get the ace-node file. I attach it here:

https://github.com/carlosparreno/sharefiles/blob/main/ace-node.js

Please, let me know if I can help somehow. I'll be off for a few days but someone from my team will back me up if you need anything.

Thanks

@aliunwala
Copy link
Contributor

From Triage meeting:
We are still not seeing the babel dependency in the ace-node.js file. (And we know our version of ace-node.js does not have any dependencies) So we think this has to be something you are loading into your environment.

The next thing for you to try is probably loading a minimal set of things and see if you still see this?

@grabowsd
Copy link

Thanks @aliunwala. I work with Carlos and I was investigating this issue further.

It looks like the new cacheFolder option in config might be the root cause of our problem. Previously the engine folder was created in ACEngineManager.js as follows:
let engineDir = path.join(__dirname, "engine");
(which results in: /node_modules/accessibility-checker/lib/engine)

and now it's:
let engineDir = path.join(config.cacheFolder, "engine");
(which results in: /private/var/folders/x_/0z7qrmqd7xjgldyxbq34yq5h0000gn/T/accessibility-checker/engine/ace-node.js
The engine folder is where the ace-node.js is stored.

How can we set the cacheFolder option in config so it's working for us as previously?

@tombrunet
Copy link
Member

You can add cacheFolder to the checker configuration file.
See https://www.npmjs.com/package/accessibility-checker#Configuration for how to set configuration.

@elycheea
Copy link

elycheea commented Dec 7, 2022

We’ve been having a similar issue in our monorepo. We were able to resolve tests locally after setting the cacheFolder but are still seeing failures in our Actions.

https://github.com/carbon-design-system/ibm-cloud-cognitive/actions/runs/3641804091/jobs/6148179111#step:6:23

@MHoov MHoov added the Bug Something isn't working label Dec 9, 2022
@tombrunet
Copy link
Member

@elycheea What did you set as a cacheFolder? Can you try an absolute path?

@tombrunet
Copy link
Member

That PR should resolve relative paths as absolute, which should be released next week, but that's something you can try if you're in a hurry.

@elycheea
Copy link

elycheea commented Dec 9, 2022

Thanks @tombrunet We’ll give it a shot — not sure if our situation ends up a bit more complicated with our monorepo though. I think my team has reached out before with other questions related to config due to our setup.

@grabowsd
Copy link

Hi @tombrunet , we’re having issues with setting up the cacheFolder. We tried adding the cacheFolder as follows:
Screenshot 2022-12-15 at 11 43 32

but we get the following error for all of our tests:
Screenshot 2022-12-15 at 11 43 47

We can see that ace-node.js exists in the path specified in cacheFolder option:
Screenshot 2022-12-15 at 11 40 54

@tombrunet
Copy link
Member

Can you please try version 3.1.42-rc.0 using the cacheFolder?

@grabowsd
Copy link

Thanks @tombrunet. I tried 3.1.42-rc.0 but I’m still getting the same error.
Screenshot 2022-12-15 at 11 43 47

I noticed that if I change the cacheFolder to just accessibility-checker the tests are passing locally but they fail in Github Actions. This also happens with version 3.1.42-rc.0.

Screenshot 2022-12-16 at 12 26 36

Screenshot 2022-12-16 at 14 30 33

@davidmenendez
Copy link

i'm taking over this issue on my team from @elycheea and wanted to follow up. has there been any update on this?

@sct-will
Copy link
Contributor

Fix is in PR: #1240

@grabowsd
Copy link

grabowsd commented Feb 2, 2023

Hi at @tombrunet and @sct-will,
Thanks for providing a fix.

I installed the latest version of accessibility-checker 3.1.43 that I believe contains the fix but I’m getting the following error: 



Screenshot 2023-02-01 at 15 07 28

I’m not sure if this is related to the same issue of cacheFolder in config but it looks like when I’m importing modules from accessibility-checker to run with Jest it cannot find string-hash module required in multiScanData.js. Is this something that I need to install separately?

Screenshot 2023-02-02 at 15 26 12

@aliunwala
Copy link
Contributor

aliunwala commented Feb 6, 2023

@grabowsd Could you try doing another npm install in the folder you are working in (Probably inside the accessibility-checker folder)

That should install string-hash (It is included in the package.json here: https://github.com/IBMa/equal-access/blob/master/accessibility-checker/package.json)

If you get any errors after that please post a screen shot again.

@davidicus
Copy link

davidicus commented Feb 8, 2023

@grabowsd Could you try doing another npm install in the folder you are working in (Probably inside the accessibility-checker folder)

That should install string-hash (It is included in the package.json here: https://github.com/IBMa/equal-access/blob/master/accessibility-checker/package.json)

If you get any errors after that please post a screen shot again.

@grabowsd This package is missing from the latest release of accessibility-checker as seen here

@tombrunet
Copy link
Member

@aliunwala Those dependencies need to be in this package.json: https://github.com/IBMa/equal-access/blob/master/accessibility-checker/src/package.json. I'll fix.

@sct-will sct-will added the user-reported Issues identified outside of the core team label Feb 9, 2023
@ErickRenteria
Copy link
Contributor

Closing issue

@tombrunet
Copy link
Member

@carlosparreno While digging into something else, I found perhaps a cleaner fix for this. Add this to your jest config instead of changing the cache folder
"transformIgnorePatterns": ["ace-node\\.js"]
By default, Jest injects babel into all js/jsx files. This tells Jest not to do that for the engine.

@grabowsd
Copy link

grabowsd commented Mar 8, 2023

@carlosparreno While digging into something else, I found perhaps a cleaner fix for this. Add this to your jest config instead of changing the cache folder "transformIgnorePatterns": ["ace-node\\.js"] By default, Jest injects babel into all js/jsx files. This tells Jest not to do that for the engine.

@tombrunet, thanks for your help! Adding transformIgnorePatterns: ["/node_modules/", "\\.pnp\\.[^\\\/]+$", "ace-node\\.js"], to our jest config solved the issue.

Note "/node_modules/", "\\.pnp\\.[^\\\/]+$" is transformIgnorePatterns default value without which accessibility-checker was throwing errors.

@carlosparreno
Copy link
Author

@tombrunet, @grabowsd, @davidicus

Thanks everybody, issue resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Ready for QA user-reported Issues identified outside of the core team
Projects
None yet
Development

No branches or pull requests

10 participants