Amphtml: Error: null is not an object (evaluating 'b.l.getEntitlementPromiseFor')

Created on 19 Mar 2020  路  6Comments  路  Source: ampproject/amphtml

This is the top error in this week's release (currently in beta): https://github.com/ampproject/amphtml/releases/tag/2003171848440

Error: null is not an object (evaluating 'b.l.getEntitlementPromiseFor')
at getEntitlementPromiseFor (https://raw.githubusercontent.com/ampproject/amphtml/2003171848440/extensions/amp-subscriptions/0.1/amp-subscriptions.js:694)

/cc @ampproject/wg-access-subscriptions

amp-subscriptions High Priority Bug Error Report access-subscriptions

Most helpful comment

Nice fix! 馃帀

All 6 comments

When the amp-subscriptions components starts up, it has an initialize function that returns a promise which other methods (mostly) wait for. initializePlatformStore (and the one other method that calls it) is called in start, however, which often has not executed before other methods are called.

For example, amp-subscriptions-google calls registerPlatform, which if run before amp-subscriptions will bind its promise handler first and try to execute before the initialize_().then promise handler in start. This is how resolvePlatform can be reached without platformStore_ ever being initialized (#27300).

This error is a similar case where url-replacements-impl:539 tries to call accessService.getAuthdataField. Again, getAuthdataField waits for the initialized_ promise, then tries to use the platformStore_ before it's initialized.

I'm guessing platformStore_ can't be set in initialize_ for some reason, so would the fix here be to establish a started or platformStoreInitialized promise/deferred that consuming methods could wait for? There are a lot of platformStore accesses in public methods, so this error is likely to crop up in more places over time too.

Do we know what the root cause is? Why has this started now?

The only changes that seem relevant or https://github.com/ampproject/amphtml/pull/27293 and https://github.com/ampproject/amphtml/pull/27309, but I'm not familiar enough with the components to dig in much further

Those two PRs were merged after the release:
https://github.com/ampproject/amphtml/releases/tag/2003171848440

It looks like https://github.com/ampproject/amphtml/pull/27265 was the only PR affecting amp-subscriptions in the release

I just diff'd the binaries from Stable and Beta and that is indeed the only change I see! I wonder how that causes these issues :thinking:

Nice fix! 馃帀

Was this page helpful?
0 / 5 - 0 ratings