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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

amp-script: improved error messages #29841

Merged
merged 10 commits into from Aug 25, 2020
Merged

Conversation

samouri
Copy link
Member

@samouri samouri commented Aug 14, 2020

Fixes #29614

For the reviewer: adding a .catch to WorkerDOM.upgrade was hacky. If an error occurs within the worker-dom code, we'd probably want an uncaught exception to throw, whereas if it is caused by the code to retrieve authorScript, then we don't want that.

The cleanest way of having the same effect would be to have the entire upgrade path within a .then() callback of the scripts, although that would then delay the start of the upgrade until after they've resolved (not that I think worker-dom actually does much work before they do, but it is what caused my hesitation).

@google-cla google-cla bot added the cla: yes label Aug 14, 2020
@samouri samouri marked this pull request as ready for review August 14, 2020 23:31
@samouri samouri force-pushed the hash-error branch 2 times, most recently from 553e3bf to e357130 Compare August 19, 2020 00:31
}
})
.catch((err) => {
// Catch errors if due to an issue with workerAndAuthorScripts rejection.

Choose a reason for hiding this comment

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

Can we just chain a catch() onto workerAndAuthorScripts above?

Copy link
Member Author

@samouri samouri Aug 20, 2020

Choose a reason for hiding this comment

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

WorkerDOM.upgrade returns a promise which is the uncaught one, so chaining onto workerAndAuthorScripts won't help.

The more obvious thing to do IMO would be to return the WorkerDOM.upgrade promise instead of workerAndAuthorScripts down below. Current method seems very intentional though, is there a reason why we don't do it?

Choose a reason for hiding this comment

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

Oh let's just do that. Don't think so.

extensions/amp-script/0.1/amp-script.js Outdated Show resolved Hide resolved
@samouri samouri merged commit 196f517 into ampproject:master Aug 25, 2020
ed-bird pushed a commit to ed-bird/amphtml that referenced this pull request Dec 10, 2020
* amp-script: improved error messages

* remove double error caused by WorkerDOM.upgrade

* need an extra space

* lint

* eh, back to createError

* less brittle check for script failure

* keep nonnull return promise

* cleanest way yay

* "or incorrect?"

* fix test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

<amp-script>: Fix and improve error messages for script hash
4 participants