ampproject / error-reporting

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

🚨 Error: Y.get(...) is not a function #27

Closed ampprojectbot closed 3 years ago

ampprojectbot commented 3 years ago

Details

Error report: link First seen: Nov 1, 2020 Frequency: ~ 7,391/day

Stacktrace

Error: Y.get(...) is not a function
    at isIntersecting (src/viewport-observer.js:117:21)

Notes

@samouri modified src/viewport-observer.js:100-119 in #30761 (Oct 23, 2020)

Seen in:

Possible assignees: @samouri

/cc @ampproject/release-on-duty

dvoytenko commented 3 years ago

@samouri a possible issue?

samouri commented 3 years ago

I think this could happen when observe and unobserve both occur before the ioCallback fires. That is the only way we could delete the callback before calling it. In this case, even though we are throwing an error it is likely harmless since we wouldn't want to fire the callback for a quickly unobserved element anyway.

We can solve simply with an if condition that checks for callback existence. Although that could potentially mask other issues. An alternative could be replacing the callback with a noop, or replacing the value with a "cancelled" object.

I'm leaning towards the simplest option (if check)