ampproject / amphtml

The AMP web component framework.
https://amp.dev
Apache License 2.0
14.89k stars 3.89k forks source link

Getting an error while using Amp Html Validator package #38401

Open skyhawk14 opened 2 years ago

skyhawk14 commented 2 years ago

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

mszylkowski commented 2 years ago

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

skyhawk14 commented 2 years ago

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)

mszylkowski commented 2 years ago

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

skyhawk14 commented 2 years ago

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

mszylkowski commented 2 years ago

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 commented 2 years ago

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})

skyhawk14 commented 2 years ago

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

zhangsu commented 1 year ago

@antiphoton @amaltas do you mind taking a look? It looks like it's been broken since Chrome 104.