Error: Null promise in layoutCallback
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
Is this still occurring?
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
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?
Add @calebcordry @powerivq
@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?
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?
@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(), soattemptToRenderCreativecould still attach a.thenhandler, andinitiateAdRequestcould resolve that promise instead of assigning to it.
@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:

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.
By device:

@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.
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.