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

Lighthouse failing with axe-core Error: Cannot read properties of undefined (reading 'actualNode') #1650

Closed
rajsite opened this issue Nov 6, 2023 · 5 comments · Fixed by #1858

Comments

@rajsite
Copy link
Member

rajsite commented Nov 6, 2023

🧹 Tech Debt

Looks like lighthouse is failing intermittently on main, since: 090ed10
See: https://storage.googleapis.com/lighthouse-infrastructure.appspot.com/reports/1699279168857-58396.report.html

And consistently with the changes proposed here: #1646
See: https://storage.googleapis.com/lighthouse-infrastructure.appspot.com/reports/1699279168857-58396.report.html

With error message:

axe-core Error: Cannot read properties of undefined (reading 'actualNode')

See:
image

Issue status: @kjohn1922 found a workaround in #1646, we should try and report it upstream to axe-core or lighthouse

@rajsite rajsite added tech debt triage New issue that needs to be reviewed labels Nov 6, 2023
@rajsite rajsite mentioned this issue Nov 6, 2023
1 task
rajsite added a commit that referenced this issue Nov 6, 2023
# Pull Request

## 🤨 Rationale

Attempt to see if upgrading dependencies stops the lighthouse internal
error reported by #1650

In the process of updating disabled the validation (error -> warn) as it
appears changes in lighthouse causes a lower score

## 👩‍💻 Implementation

Upgraded the lighthouse version

## 🧪 Testing

Relying on CI.

## ✅ Checklist

- [x] I have updated the project documentation to reflect my changes or
determined no changes are needed.
@rajsite
Copy link
Member Author

rajsite commented Nov 8, 2023

@kjohn1922 thanks for digging in and finding a workaround for what was breaking axe core in lighthouse. If you're feeling ambitious can try to reproduce and report it upstream to https://github.com/dequelabs/axe-core

@m-akinc m-akinc removed the triage New issue that needs to be reviewed label Nov 8, 2023
@rajsite
Copy link
Member Author

rajsite commented Feb 7, 2024

Found a way to reproduce the axe-core error in dev tools when running against lighthouse:

  1. Navigate to a built page that causes the error in lighthouse, i.e. currently: https://nimble.ni.dev/storybook/example-client-app/#/customapp
  2. Open dev tools, in the sources tab under breakpoints enable Pause on caught exceptions
  3. In dev tools in the console run the latest axe-core on the page, i.e.
    (((fn)=>window.axe?fn():document.body.append(Object.assign(document.createElement('script'),{src:'https://unpkg.com/axe-core/axe.js',onload:fn})))(()=>axe.run().then(results=>console.log(results)).catch(err=>console.error(err))));
    Note: the script is loading unminified code and targeting the latest version. As of writing the version resolved to https://unpkg.com/axe-core@4.8.4/axe.js
  4. The script will download and run, may take a few seconds, but should break on the line resulting in an error

A bookmarklet version of the script:

javascript:(function()%7B(((fn)%3D%3Ewindow.axe%3Ffn()%3Adocument.body.append(Object.assign(document.createElement('script')%2C%7Bsrc%3A'https%3A%2F%2Funpkg.com%2Faxe-core%2Faxe.js'%2Conload%3Afn%7D)))(()%3D%3Eaxe.run().then(results%3D%3Econsole.log(results)).catch(err%3D%3Econsole.error(err))))%3B%7D)()%3B

rajsite added a commit that referenced this issue Feb 7, 2024
# Pull Request

## 🤨 Rationale

Disables the Card in the Angular and Blazor example apps as it breaks
axe-core tooling used by lighthouse, see:
#1650

## 👩‍💻 Implementation

Disabled the nimble-card in the Angular and Blazor apps

Re-enabled the accessibility lighthouse error. The thought is that with
this change the accessibility score will be reliably calculated and not
cause intermittent blocking of merges, only blocks on merges that
further regress the score. If it is not the case and lighthouse becomes
unreliable calculating the score we can disable it again.

Removed the exisiting comment for an issue to get us back to 0.9 score
as there are multiple issues impacting our score now.

## 🧪 Testing

Relying on lighthouse CI execution.

## ✅ Checklist

- [x] I have updated the project documentation to reflect my changes or
determined no changes are needed.
@rajsite
Copy link
Member Author

rajsite commented Feb 7, 2024

The lighthouse update merged as part of #1786 caused this card issue to come-up again so the card was disabled in the example app and the accessibility assertions re-enabled as part of #1809

@rajsite rajsite self-assigned this Feb 7, 2024
@rajsite
Copy link
Member Author

rajsite commented Feb 7, 2024

Assigning to myself to file an issue upstream to axe-core

@rajsite
Copy link
Member Author

rajsite commented Feb 22, 2024

Created a minimal reproducing example that causes the lighthouse failure

live page: https://axecore-lighthouse-failure.glitch.me/
edit page: https://glitch.com/edit/#!/axecore-lighthouse-failure

Reported an issue to axe-core so hopefully they can handle shadow roots better: dequelabs/axe-core#4335

Reported an issue to lighthouse so hopefully they can be more robust to axe-core failures and still generate accessibility scores: GoogleChrome/lighthouse#15828

Marking the issue blocked. If either the lighthouse or axe-core issue is resolved we may be able to unblock this issue and re-enable the nimble-card in the angular app:

<!-- Disabled as it breaks accessibility tooling, see: https://github.com/ni/nimble/issues/1650
<div class="sub-container">
<div class="container-label">Card</div>
<nimble-card>
<span slot="title">Title of the card</span>
<nimble-number-field>Numeric field 1</nimble-number-field>
<nimble-number-field>Numeric field 2</nimble-number-field>
<nimble-select>
<nimble-list-option value="1">Option 1</nimble-list-option>
<nimble-list-option value="2">Option 2</nimble-list-option>
<nimble-list-option value="3">Option 3</nimble-list-option>
</nimble-select>
</nimble-card>
</div>
-->

@rajsite rajsite added the blocked Blocked on a third-party issue label Feb 22, 2024
@rajsite rajsite removed their assignment Feb 22, 2024
rajsite added a commit that referenced this issue Feb 22, 2024
# Pull Request

## 🤨 Rationale

The card was previously disabled after it started resulting in axe-core
completely failing. After reporting to axe-core their comment in
dequelabs/axe-core#4335 (comment)
made me think we can workaround the axe-core issue by wrapping the slot
in a span and targeting that instead for aria.

While not necessary for runtime behavior or accessibility, the
workaround adds minimal overhead and complexity. Does not need to be
removed after the axe-core fix. Fixes #1650

## 👩‍💻 Implementation

Wraps the slot in a span and use that as the aria target. 

## 🧪 Testing

Can see the PR has a passing lighthouse score with the card re-enabled.

## ✅ Checklist

- [x] I have updated the project documentation to reflect my changes or
determined no changes are needed.
@rajsite rajsite removed the blocked Blocked on a third-party issue label Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

2 participants