amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

Error: Null promise in layoutCallback

Open zhouyx opened this issue 7 years ago • 12 comments

Error: Null promise in layoutCallback at Error (https://raw.githubusercontent.com/ampproject/amphtml/1902191749350/src/log.js:540) at apply (https://raw.githubusercontent.com/ampproject/amphtml/1902191749350/src/log.js:244) at apply (https://raw.githubusercontent.com/ampproject/amphtml/1902191749350/src/log.js:257) at error (https://raw.githubusercontent.com/ampproject/amphtml/1902191749350/extensions/amp-a4a/0.1/amp-a4a.js:987) at attemptToRenderCreative (https://raw.githubusercontent.com/ampproject/amphtml/1902191749350/extensions/amp-a4a/0.1/amp-a4a.js:972) at implementation_ (https://raw.githubusercontent.com/ampproject/amphtml/1902191749350/src/custom-element.js:598) at (https://raw.githubusercontent.com/ampproject/amphtml/1902191749350/src/utils/promise.js:75) at (https://raw.githubusercontent.com/ampproject/amphtml/1902191749350/src/utils/promise.js:74) at implementation_ (https://raw.githubusercontent.com/ampproject/amphtml/1902191749350/src/custom-element.js:596)

go/amp-error/CJnxr-aJ1pbyEw go/amp-error/CNmRyfmivLf3Nw

zhouyx avatar Feb 26 '19 21:02 zhouyx

Is this still occurring?

keithwrightbos avatar Jul 31 '19 16:07 keithwrightbos

as of today, still happing 10K+ a day https://pantheon.corp.google.com/errors?service=default-cdn-1p&time=P1D&filter=text:Null%20promise%20in%20layoutCallback&order=COUNT_DESC&resolution=OPEN&resolution=ACKNOWLEDGED&project=amp-error-reporting&authuser=0

lannka avatar Dec 03 '19 23:12 lannka

What appears to be happening here is that the layoutCallback handler in the Amp4A component tries to call attemptToRenderCreative. However, the adPromise_ (which should resolve with the creative metadata) isn't initialized until initiateAdRequest is called, which happens in either refresh or onLayoutMeasure.

I suspect these are rarely or never executed before the layoutCallback, meaning the initial attempt to render the creative almost always results in this error, and only after a refresh or re-layout occurs is the promise defined and the creative able to render.

If this is indeed the case, I wonder if layoutCallback should try to call refresh or initiateAdRequest before attempting to render the creative. Alternately, adPromise_ could be initially defined as a new Deferred(), so attemptToRenderCreative could still attach a .then handler, and initiateAdRequest could resolve that promise instead of assigning to it.

@keithwrightbos @lannka WDYT?

rcebulko avatar Mar 19 '20 16:03 rcebulko

Add @calebcordry @powerivq

zhouyx avatar Mar 23 '20 18:03 zhouyx

@rcebulko layoutMeasure should happen before layoutCallback.

Started looking into this error, and realized that it is wrapped in a dev().error() My understanding was that we get rid of dev errors in prod, so I am a bit confused why this shows up at all. Maybe I am missing something?

calebcordry avatar Mar 23 '20 21:03 calebcordry

My understanding was that we get rid of devAssert assertions & friends in prod, but dev().error() is just how we wrap errors for logging. Maybe @jridgewell can confirm this?

rcebulko avatar Mar 23 '20 21:03 rcebulko

@calebcordry I can confirm that dev().error() reports an error, while devAssert gets removed. Is this a user error in configuration, ie. the publisher is trying to use the element the wrong way? If so, we can make this a user().error(). Otherwise, would the suggestion above be a reasonable fix? If you can confirm, I'll throw a PR together with either resolution

Alternately, adPromise_ could be initially defined as a new Deferred(), so attemptToRenderCreative could still attach a .then handler, and initiateAdRequest could resolve that promise instead of assigning to it.

rcebulko avatar Apr 28 '20 15:04 rcebulko

@calebcordry @powerivq Until recently, this was occurring a bit over 100k times per day. As of the 4/24 release to Beta/Experimental (2004240001480), this error exploded to ~4 million per day, but only on the Experimental channel, and logs suggest predominantly on Android user-agents. See the metrics below:

image image

This massive spike on 4/24 is believe to be attributed to this error. Note that it does not appear to impact Beta, suggesting this is related to an experiment being run. Note that if this experiment is enabled in production, It would cause on the order of 800 million errors daily.

rcebulko avatar Apr 30 '20 17:04 rcebulko

By device: image

rcebulko avatar Apr 30 '20 17:04 rcebulko

@rcebulko sorry this slipped through the cracks. As far as the spike I think this is real known error fixed by https://github.com/ampproject/amphtml/pull/28070 so this is probably good it showed up in our logs.

Yeah I was wrong about dev().error I am looking more now to determine what is happening to cause this when the bug does not exist.

calebcordry avatar Apr 30 '20 17:04 calebcordry

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[bot] avatar Dec 02 '21 02:12 stale[bot]

i have the issue too on this page after updating wordpress.

may i know how to fix this?

workjmc avatar Nov 28 '23 15:11 workjmc