amphtml: : "Illegal mutation" error should provide more information
Currently, if I try to use setInterval()
or setTimeout()
on load, or if I try to make mutations >5 seconds after a user gesture, I get an error message like this:
[amp-script] amp-script[script="myscript"].js was terminated due to illegal mutation.
-
Most importantly, it would be much more useful to know what the illegal mutation was. Otherwise, as a developer, I don’t know what I’ve done wrong. If I’ve tried to make changes 5 seconds after a user interaction, or tried a delayed mutation after the hydration phrase on load, I should be told exactly what that is, so I know not to do it again!
-
Less importantly, if the error occurs in an inline script, it would be helpful to be told that instead of
amp-script[script="myscript"].js
.
This probably seems trivial, but letting developers know what they’ve done wrong will help them find and fix the error quickly!
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 28 (19 by maintainers)
Yeah, still can’t reproduce.
So, if it’s easy to check whether the sanitizer is doing some sanitizing without throwing a notification of some sort, can we do that?
In the meantime, how about something like this:
<amp-script>
containers, a user action has to happen first.<amp-script>
containers, a user action has to happen first.<amp-script>
containers, a user action has to happen first.I’m not sure when PROPERTIES gets thrown. Maybe someone could point to me the code? Are we actually throwing ATTRIBUTES sometimes when we should be throwing PROPERTIES?
I know my language there is wordy. I just haven’t succeeded in compressing the bit about variable-sized
<amp-script>
containers. But of course this string could just be stored once…Hi, we are using amp-script to identify the device ( iOS/Android ) and show the app download image. It worked fine so far, but suddenly we are getting the below exception.
[amp-script] Dropped 2x “ATTRIBUTES” mutation(s); user gesture is required with [layout=container].
Please advise how to debug this issue
@samouri thank you, I now that this is not a good place to talk about, I miss understood the issue title. actually, I fixed it, it was because of the wrong place to wait for getBoundingClientRectAsync, now https://github.com/ampproject/worker-dom/issues/835 is the problem.
@sayjeyhi, I was able to run your example without any errors. Can you provide a fully reproducible case?
Then how about combining
ATTRIBUTES
andPROPERTIES
into a single message:Blocked n attempts to modify DOM element attributes, properties, or styles. For variable-sized
<amp-script>
containers, a user action has to happen first.Going to make that issue today, I was totally unable to reproduce these silent failures. And I was able to get the CHARACTER_DATA error.
Maybe it was me who was failing, not at all silently…