ampproject / error-reporting

Contains production error tracking issues.
Apache License 2.0
2 stars 5 forks source link

🚨 Error: Cannot read property 'hasAttribute' of undefined #46

Closed ampprojectbot closed 3 years ago

ampprojectbot commented 3 years ago

Details

Error report: link First seen: May 2, 2020 Frequency: ~ 2,240/day

Stacktrace

Error: Cannot read property 'hasAttribute' of undefined
    at hasAttribute (src/service/navigation.js:757:23)
    at viewerInterceptsNavigation (src/service/navigation.js:560:15)

Notes

@ammaxwell modified src/service/navigation.js:735-775 in #27649 (Apr 24, 2020) @ammaxwell modified src/service/navigation.js:559-562 in #27649 (Apr 24, 2020)

Seen in:

Possible assignees: @ammaxwell

/cc @ampproject/release-on-duty

rcebulko commented 3 years ago

image When is it possible for ampdoc.getRootNode().documentElement to be undefined? /cc @ampproject/wg-viewers since the stacktrace doesn't seem to provide many clues. Seems to be occurring only on Android browsers.

dvoytenko commented 3 years ago

getRootNode() is defined as a !Document|!ShadowRoot. There's no documentElement in ShadowRoot interface. I'm a bit surprised we are not getting a compiler warning here. But in either case - this needs to be fixed.

samouri commented 3 years ago

Can shadow root docs be opted in to navigation interception? How do shadow docs specify capabilities/opt-ins?

dvoytenko commented 3 years ago

Navigation is definitely used. The viewer-interception is not possible, of course. So the fix here could simply be to check that documentElement exists. Or simply ampdoc.getRootNode().documentElement?.hasAttribute(...) would be enough. Though a cleaner approach would probably be explicitly checking for a ampdoc.isSingleDoc().