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

Error: Cannot call method 'requestMeasure' of undefined #18207

Closed
adelinamart opened this issue Sep 19, 2018 · 10 comments
Closed

Error: Cannot call method 'requestMeasure' of undefined #18207

adelinamart opened this issue Sep 19, 2018 · 10 comments
Labels
Milestone

Comments

@adelinamart
Copy link
Contributor

@aghassemi can you check the following production error. Thanks.

Error: Impossible d’obtenir la propriété « requestMeasure » d’une référence null ou non définie
at (https://raw.githubusercontent.com/ampproject/amphtml/1809142227020/src/focus-history.js:120)
at (https://raw.githubusercontent.com/ampproject/amphtml/1809142227020/src/service/viewport/viewport-impl.js:559)
at animateScrollIntoViewInternal_ (https://raw.githubusercontent.com/ampproject/amphtml/1809142227020/src/service/viewport/viewport-impl.js:539)

Version
011809142227020

https://pantheon.corp.google.com/errors/CP6dwsLQn4P4uQE?service=default-cdn-1p&time=P1D&project=amp-error-reporting

@aghassemi
Copy link
Contributor

reassigning to @jridgewell

@aghassemi aghassemi assigned jridgewell and unassigned aghassemi Sep 19, 2018
@ampprojectbot
Copy link
Member

This is a high priority issue but it hasn't been updated in awhile. @jridgewell Do you have any updates?

2 similar comments
@ampprojectbot
Copy link
Member

This is a high priority issue but it hasn't been updated in awhile. @jridgewell Do you have any updates?

@ampprojectbot
Copy link
Member

This is a high priority issue but it hasn't been updated in awhile. @jridgewell Do you have any updates?

@Enriqe
Copy link
Contributor

Enriqe commented Feb 1, 2019

This is still being logged in version 1901302225410

Error: Cannot call method 'requestMeasure' of undefined
at (https://raw.githubusercontent.com/ampproject/amphtml/1901242049580/src/focus-history.js:121)
at innerHeight (https://raw.githubusercontent.com/ampproject/amphtml/1901242049580/src/service/viewport/viewport-impl.js:833)
at leaveFullOverlayMode (https://raw.githubusercontent.com/ampproject/amphtml/1901242049580/src/service/viewport/viewport-impl.js:775)

@samouri
Copy link
Member

samouri commented Jan 15, 2020

@jridgewell / @choumx: this is still marked P1 and yet hasn't had activity since 2019. Is there action for us to take here?

I see this recent message in our error logs:

version: "011912180046560"

2020-01-14 15:36:04.216 EST
Error: Cannot read property 'requestMeasure' of undefined
  at requestMeasure (https://raw.githubusercontent.com/ampproject/amphtml/1912180046560/src/service/resources-impl.js:627:10) 
  at https://raw.githubusercontent.com/ampproject/amphtml/1912180046560/src/service/vsync-impl.js:470:16 
  at callTask_ (https://raw.githubusercontent.com/ampproject/amphtml/1912180046560/src/service/vsync-impl.js:426:8) 
  at handler_ (https://raw.githubusercontent.com/ampproject/amphtml/1912180046560/src/pass.js:109:4) 
  at pass_ (https://raw.githubusercontent.com/ampproject/amphtml/1912180046560/src/pass.js:55:6) 
  at https://raw.githubusercontent.com/ampproject/amphtml/1912180046560/src/service/timer-impl.js:83:8

@jridgewell
Copy link
Contributor

Wanna investigate it? 😉

@samouri samouri assigned samouri and unassigned jridgewell Jan 15, 2020
@dreamofabear
Copy link

https://github.com/ampproject/amphtml/blob/1912180046560/src/service/resources-impl.js#L627

Looks like there's more than one cause. How prominent is the error? E.g. top N.

@samouri
Copy link
Member

samouri commented Jan 16, 2020

While there are a few others, this is the most prominent cause of this error by far. In terms of this error vs. others, this one is pretty low on the occurrences list.

The problem snippet is this:

const ampElements = element.getElementsByClassName('i-amphtml-element');
for (let i = 0; i < ampElements.length; i++) {
  const r = Resource.forElement(ampElements[i]);
  r.requestMeasure(); // <--- `r` is undefined
}

While getElementsByClassName returns a live-list, I don't think an element removal (making ampElements[i] undefined), could be a cause for this. Mostly because no other code could run in between those two lines.

So the culrpit must be Resource.forElement returning undefined for an element that has a classname i-amphtml-element. The file that adds that classname and manages adding/removing the resource is custom-element.js. What seems most likely to me is that a disconnect event is removing the resource without removing the classname.

@dreamofabear dreamofabear changed the title Cannot call method 'requestMeasure' of undefined Error: Cannot call method 'requestMeasure' of undefined Jun 26, 2020
@stale
Copy link

stale bot commented Dec 19, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Stale Inactive for one year or more label Dec 19, 2021
@stale stale bot closed this as completed Dec 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants