amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

Getting an error while using Amp Html Validator package

Open skyhawk14 opened this issue 3 years ago • 7 comments

Description

Facing issue with amphtml-validator v1.0.35 . While using validateString for validating AMP email it is throwing an error. Few months back this was working fine. Getting below error message. Anyone aware about any recent major change with the package dependency or about the issue which I am getting?

Reproduction Steps

Issue is replicated here: https://codesandbox.io/s/happy-cannon-kdrbxt?file=/src/App.js

Relevant Logs

{
    "message": "Assertion failed: WebAssembly is uninitialized"
}

Browser(s) Affected

No response

OS(s) Affected

No response

Device(s) Affected

No response

AMP Version Affected

No response

skyhawk14 avatar Aug 11 '22 09:08 skyhawk14

Hi, check out https://codesandbox.io/s/mystifying-minsky-ijsei4?file=/src/App.js which worked for me. When clicking on the button, it shows the error properly:

image

mszylkowski avatar Aug 11 '22 15:08 mszylkowski

Hi @mszylkowski , Thanks for looking at the issue. But for me I am getting this when I tried using the link which you shared. image

I am trying this on Chrome Version 104.0.5112.79 (Official Build) (arm64)

skyhawk14 avatar Aug 11 '22 15:08 skyhawk14

That is interesting, I was on Chrome 103 (working) and just updated to Chrome 104 and it stopped working...

mszylkowski avatar Aug 11 '22 15:08 mszylkowski

This explains its not working in chrome with the latest build but it is not working in other other browsers like safari (Version 15.5 (17613.2.7.1.8)) and in Firefox also. Is there any update happen with validator_wasm.js , are you aware about it? @mszylkowski

skyhawk14 avatar Aug 11 '22 15:08 skyhawk14

Found a way to fix this temporarily: const instance = await amphtmlValidator.getInstance("https://cdn.ampproject.org/v0/validator.20211101.deprecated.js");

The underlying error comes from a breakage of the API since https://github.com/ampproject/amphtml/issues/36110. I'll direct this issue towards someone that can fix the validator, and comment on that issue.

mszylkowski avatar Aug 11 '22 16:08 mszylkowski

I've added a comment that the NPM package doesn't work properly.

FYI:

Another alternative is to directly use the script: <script src="https://cdn.ampproject.org/v0/validator_wasm.js"></script>

and doing window.amp.validator.init().then(() => {doHereYourStuff})

mszylkowski avatar Aug 11 '22 17:08 mszylkowski

@mszylkowski Second approach works for me. First approach of using javascript validator we can't do it as it as this is deprecated.

skyhawk14 avatar Aug 15 '22 01:08 skyhawk14