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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Wait for story impl to resolve #13829

Merged
merged 3 commits into from Mar 7, 2018
Merged

馃悰 Wait for story impl to resolve #13829

merged 3 commits into from Mar 7, 2018

Conversation

calebcordry
Copy link
Member

amp-story-auto-ads had a race condition where it was setting a pointer to the amp-story impl synchronously, even though the getImpl() method is async.

This wraps that bit of code in a promise.

@@ -117,7 +120,7 @@ export class AmpStoryAutoAds extends AMP.BaseElement {
Services.extensionsFor(this.win)./*OK*/installExtensionForDoc(
ampdoc, MUSTACHE_TAG);

ampStoryElement.getImpl().then(impl => {
this.storyImplPromise_ = ampStoryElement.getImpl().then(impl => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you might just return this promise, it will block the lifecycle of the element.
but please test it out if i am right

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. changed.

@@ -71,6 +71,9 @@ export class AmpStoryAutoAds extends AMP.BaseElement {
constructor(element) {
super(element);

/** @private {?Promise} */
this.storyImplPromise_ = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops. done

@calebcordry calebcordry merged commit 91c0ec2 into ampproject:master Mar 7, 2018
@calebcordry calebcordry deleted the wait-for-impl branch March 7, 2018 17:15
RanAbram pushed a commit to RanAbram/amphtml that referenced this pull request Mar 12, 2018
* wait for story impl

* block on buildCallback

* remove unused var
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants