ampproject / ampproject/amphtml
Uncaught (in promise) Error
- Dominant language
- JavaScript
- Stars
- 14.9k
- Forks
- 4.1k
- PR merge metrics
- No merged PRs in 30d
Description
### Description
I'm trying to implement amp-subscriptions to some gated articles I have on a website locally. I've gone through the documentation of implementing it but I keep getting this error in the console that doesn't explain much to me.

### Reproduction Steps
1. Added amp-subscription script in head.
```
```
2. Added structured data
```
{
"@context": "http://schema.org",
"@type": "BlogPosting",
"headline": "{{ entry.title }}",
"image": {
"@type": "ImageObject",
"url": "{{ imageUrl }}",
"width": 696,
"height": 392
},
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "{{ siteUrl ~ craft.app.request.absoluteUrl }}"
},
"description": "{{ entry.shortDescription }}",
"datePublished": "{{ entry.postDate|date() }}",
"dateModified": "{{ entry.dateUpdated|date() }}",
"author": {
"@type": "Person",
"name": "{{ entry.author.fullName }}"
},
"publisher": {
"@type": "Organization",
"name": "Toast, Inc.",
"logo": {
"@type": "ImageObject",
"url": "https://d2w1ef2ao9g8r9.cloudfront.net/images/Toast_Logo/Toast+Logo/Web/Color/toastlogo-web-color.png",
"width": 275
}
},
"isAccessibleForFree": false,
"hasPart": {
"@type": "WebPageElement",
"isAccessibleForFree": false,
"cssSelector": ".gated-article"
},
"isPartOf": {
"@type": ["CreativeWork", "Product"],
"name" : "On the Line",
"productID": "on-the-line"
}
}
```
3. Added Amp subscription json
```
{
"services": [
{
"authorizationUrl": "http://toast.local/actions/marketo-integration/default/authgate?rid=READER_ID&url=SOURCE_URL",
"actions": {
"login": "http://toast.local/blog/on-the-line/subscribe?rid=READER_ID&url=SOURCE_URL",
"subscribe": "http://toast.local/blog/on-the-line/subscribe"
}
}
],
"fallbackEntitlement": {
"source": "fallback",
"granted": true,
"grantReason": "SUBSCRIBER",
"data": {
"isLoggedIn": true
}
}
}
```
### Relevant Logs
```shell
Uncaught (in promise) Error:
at qb (config.js:315)
at V.createError (config.js:361)
at xb.check (config.js:713)
qb @ config.js:315
V.createError @ config.js:361
xb.check @ config.js:713
Promise.then (async)
g.start @ amp-subscriptions.js:144
(anonymous) @ amp-subscriptions.js:887
Bd @ service-helpers.js:366
N @ service-helpers.js:126
(anonymous) @ extensions-impl.js:423
g.addDocFactory @ extensions-impl.js:457
g.addService @ extensions-impl.js:422
(anonymous) @ amp-subscriptions.js:886
f @ amp-subscriptions.js:885
g.registerExtension @ extensions-impl.js:174
(anonymous) @ runtime.js:186
Promise.then (async)
(anonymous) @ runtime.js:182
Gi @ chunk.js:203
Ci.kf @ chunk.js:422
(anonymous) @ chunk.js:478
Promise.then (async)
Ji @ chunk.js:477
Ci.Aa @ chunk.js:496
Ci.runForStartup @ chunk.js:381
Di @ chunk.js:72
pm @ runtime.js:296
b @ runtime.js:197
c.AMP.push @ runtime.js:229
(anonymous) @ amp-subscriptions-0.1.js:1
```
### Browser(s) Affected
_No response_
### OS(s) Affected
_No response_
### Device(s) Affected
_No response_
### AMP Version Affected
_No response_
Contributor guide
Research direction
Reproduce the issue with the supplied amp-subscriptions markup, then start at amp-subscriptions.js:144 and follow the reported checks in config.js:315 and config.js:713. Compare the configuration and console output to determine why startup rejects it; done means the reproduced page no longer emits the uncaught promise error and the subscription setup still works.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100